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
2c050d31
"...HTSeq/git@gitbio.ens-lyon.fr:hpolvech/nextflow_TP2017.git" did not exist on "8aee48b98cbafdecd62fa5a2652d012df0483a6e"
Commit
2c050d31
authored
3 years ago
by
nfontrod
Browse files
Options
Downloads
Patches
Plain Diff
src/commit.rs: add handle for .borgignore file
parent
8acb786a
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
+33
-8
33 additions, 8 deletions
src/commit.rs
with
33 additions
and
8 deletions
src/commit.rs
+
33
−
8
View file @
2c050d31
...
...
@@ -53,23 +53,48 @@ pub fn delete_commit(commit: &str, borg_path: &PathBuf) {
}
}
/// Checks if .borgignore file exists in the project folder
///
/// # Arguments:
/// * borg_folder: Path to .borg folder
///
/// # Return:
/// A tuple containing:
/// * A boolean indicating if .borgignore file exits
/// * The path to this borgignore file
fn
check_if_borgignore_exists
(
borg_folder
:
&
PathBuf
)
->
(
bool
,
PathBuf
)
{
let
mut
project_folder
=
borg_folder
.parent
()
.unwrap
()
.to_path_buf
();
project_folder
.push
(
".borgignore"
);
(
project_folder
.is_file
(),
project_folder
)
}
/// 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
)
{
let
(
borg_folder
,
results_folder
)
=
check_path
();
let
(
has_ignore
,
borgignore
)
=
check_if_borgignore_exists
(
&
borg_folder
);
if
commit_id
==
String
::
from
(
""
)
{
commit_id
=
get_current_commit
();
}
if
update
{
delete_commit
(
&
commit_id
,
&
borg_folder
);
}
let
mut
margs
:
Vec
<&
str
>
=
vec!
[
"create"
,
"--stats"
,
"--progress"
,
"--compression"
,
&
compression
,
];
if
has_ignore
{
margs
.push
(
"--exclude-from"
);
margs
.push
(
borgignore
.to_str
()
.unwrap
());
}
let
cmd_part
=
format!
(
"{}::{}"
,
borg_folder
.to_str
()
.unwrap
(),
commit_id
);
margs
.push
(
&
cmd_part
);
margs
.push
(
results_folder
.to_str
()
.unwrap
());
let
mut
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
())
.args
(
margs
)
.stdout
(
Stdio
::
piped
())
.spawn
()
.unwrap_or_else
(|
e
|
{
...
...
@@ -77,7 +102,7 @@ pub fn commit(compression: String, mut commit_id: String, update: bool) {
exit
(
8
);
});
let
ecode
=
output
.wait
()
.expect
(
"error"
);
match
ecode
.code
()
.unwrap
()
{
match
ecode
.code
()
.unwrap
()
{
0
=>
(),
num
=>
{
eprintln!
(
"{}"
,
ecode
.to_string
());
...
...
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