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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LBMC
Hub
git_borg_linker
Commits
450cc547
Commit
450cc547
authored
May 12, 2022
by
nfontrod
Browse files
Options
Downloads
Patches
Plain Diff
Add silent commit function
parent
d90615a3
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/checkout.rs
+29
-1
29 additions, 1 deletion
src/checkout.rs
with
29 additions
and
1 deletion
src/checkout.rs
+
29
−
1
View file @
450cc547
...
...
@@ -4,6 +4,34 @@ use std::{
process
::{
exit
,
Command
},
};
/// Create a commit of the results folder named as the current git commit id
fn
silent_commit
(
compression
:
String
,
mut
commit_id
:
String
,
update
:
bool
)
{
let
(
borg_folder
,
results_folder
)
=
commit
::
check_path
();
if
commit_id
==
String
::
from
(
""
)
{
commit_id
=
commit
::
get_current_commit
();
}
if
update
{
commit
::
delete_commit
(
&
commit_id
,
&
borg_folder
);
}
let
output
=
Command
::
new
(
"borg"
)
.arg
(
"create"
)
.arg
(
"--stats"
)
.arg
(
"--progress"
)
.arg
(
"--compression"
)
.arg
(
compression
)
.arg
(
format!
(
"{}::{}"
,
borg_folder
.to_str
()
.unwrap
(),
commit_id
))
.arg
(
results_folder
.to_str
()
.unwrap
())
.output
()
.unwrap
();
match
output
.status
.code
()
.unwrap
()
{
0
=>
(),
num
=>
{
eprintln!
(
"{}"
,
String
::
from_utf8
(
output
.stderr
)
.unwrap
());
exit
(
num
);
}
}
}
/// Check if two commits are differents
pub
fn
is_diff
(
commit1
:
&
str
,
commit2
:
&
str
,
borg_folder
:
&
PathBuf
)
->
bool
{
let
archive1
=
format!
(
"{}::{}"
,
borg_folder
.to_str
()
.unwrap
(),
commit1
);
...
...
@@ -70,7 +98,7 @@ pub fn prepare_checkout() {
check_if_current_commit_exits
(
&
borg_path
,
&
commit_id
);
// Create an archive with the content of the current commit
let
tmp_name
=
format!
(
"{}-tmp"
,
commit_id
);
commit
::
commit
(
String
::
from
(
"none"
),
tmp_name
.clone
(),
false
);
silent_
commit
(
String
::
from
(
"none"
),
tmp_name
.clone
(),
false
);
let
res
=
is_diff
(
&
commit_id
,
&
tmp_name
,
&
borg_path
);
commit
::
delete_commit
(
&
tmp_name
,
&
borg_path
);
if
res
{
...
...
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