Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
git_borg_linker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LBMC
Hub
git_borg_linker
Commits
0ffe76d7
Commit
0ffe76d7
authored
3 years ago
by
nfontrod
Browse files
Options
Downloads
Patches
Plain Diff
src/commit.rs: update to display borg commit progression
parent
90d51bf3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/commit.rs
+11
-8
11 additions, 8 deletions
src/commit.rs
with
11 additions
and
8 deletions
src/commit.rs
+
11
−
8
View file @
0ffe76d7
use
crate
::
init
;
use
crate
::
init
;
use
std
::{
use
std
::{
path
::
PathBuf
,
path
::
PathBuf
,
process
::{
exit
,
Command
},
process
::{
exit
,
Command
,
Stdio
},
};
};
/// Check if .borg repository and results folder exists
/// Check if .borg repository and results folder exists
...
@@ -37,7 +37,6 @@ pub fn get_current_commit() -> String {
...
@@ -37,7 +37,6 @@ pub fn get_current_commit() -> String {
commit
commit
}
}
/// function that deletes commit if needed
/// function that deletes commit if needed
pub
fn
delete_commit
(
commit
:
&
str
,
borg_path
:
&
PathBuf
)
{
pub
fn
delete_commit
(
commit
:
&
str
,
borg_path
:
&
PathBuf
)
{
let
output
=
Command
::
new
(
"borg"
)
let
output
=
Command
::
new
(
"borg"
)
...
@@ -54,7 +53,6 @@ pub fn delete_commit(commit: &str, borg_path: &PathBuf) {
...
@@ -54,7 +53,6 @@ pub fn delete_commit(commit: &str, borg_path: &PathBuf) {
}
}
}
}
/// Create a commit of the results folder named as the current git commit id
/// Create a commit of the results folder named as the current git commit id
pub
fn
commit
(
compression
:
String
,
mut
commit_id
:
String
,
update
:
bool
)
{
pub
fn
commit
(
compression
:
String
,
mut
commit_id
:
String
,
update
:
bool
)
{
let
(
borg_folder
,
results_folder
)
=
check_path
();
let
(
borg_folder
,
results_folder
)
=
check_path
();
...
@@ -64,7 +62,7 @@ pub fn commit(compression: String, mut commit_id: String, update: bool) {
...
@@ -64,7 +62,7 @@ pub fn commit(compression: String, mut commit_id: String, update: bool) {
if
update
{
if
update
{
delete_commit
(
&
commit_id
,
&
borg_folder
);
delete_commit
(
&
commit_id
,
&
borg_folder
);
}
}
let
output
=
Command
::
new
(
"borg"
)
let
mut
output
=
Command
::
new
(
"borg"
)
.arg
(
"create"
)
.arg
(
"create"
)
.arg
(
"--stats"
)
.arg
(
"--stats"
)
.arg
(
"--progress"
)
.arg
(
"--progress"
)
...
@@ -72,12 +70,17 @@ pub fn commit(compression: String, mut commit_id: String, update: bool) {
...
@@ -72,12 +70,17 @@ pub fn commit(compression: String, mut commit_id: String, update: bool) {
.arg
(
compression
)
.arg
(
compression
)
.arg
(
format!
(
"{}::{}"
,
borg_folder
.to_str
()
.unwrap
(),
commit_id
))
.arg
(
format!
(
"{}::{}"
,
borg_folder
.to_str
()
.unwrap
(),
commit_id
))
.arg
(
results_folder
.to_str
()
.unwrap
())
.arg
(
results_folder
.to_str
()
.unwrap
())
.output
()
.stdout
(
Stdio
::
piped
())
.unwrap
();
.spawn
()
match
output
.status
.code
()
.unwrap
()
{
.unwrap_or_else
(|
e
|
{
eprintln!
(
"An error occured during borg create ! {}"
,
e
);
exit
(
8
);
});
let
ecode
=
output
.wait
()
.expect
(
"error"
);
match
ecode
.code
()
.unwrap
()
{
0
=>
(),
0
=>
(),
num
=>
{
num
=>
{
eprintln!
(
"{}"
,
String
::
from_utf8
(
output
.stderr
)
.unwrap
());
eprintln!
(
"{}"
,
ecode
.to_string
());
exit
(
num
);
exit
(
num
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment