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
2c050d31
Commit
2c050d31
authored
Jun 10, 2022
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
Show 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) {
...
@@ -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
/// 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
();
let
(
has_ignore
,
borgignore
)
=
check_if_borgignore_exists
(
&
borg_folder
);
if
commit_id
==
String
::
from
(
""
)
{
if
commit_id
==
String
::
from
(
""
)
{
commit_id
=
get_current_commit
();
commit_id
=
get_current_commit
();
}
}
if
update
{
if
update
{
delete_commit
(
&
commit_id
,
&
borg_folder
);
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"
)
let
mut
output
=
Command
::
new
(
"borg"
)
.arg
(
"create"
)
.args
(
margs
)
.arg
(
"--stats"
)
.arg
(
"--progress"
)
.arg
(
"--compression"
)
.arg
(
compression
)
.arg
(
format!
(
"{}::{}"
,
borg_folder
.to_str
()
.unwrap
(),
commit_id
))
.arg
(
results_folder
.to_str
()
.unwrap
())
.stdout
(
Stdio
::
piped
())
.stdout
(
Stdio
::
piped
())
.spawn
()
.spawn
()
.unwrap_or_else
(|
e
|
{
.unwrap_or_else
(|
e
|
{
...
...
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