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
9beee746
Verified
Commit
9beee746
authored
Feb 1, 2023
by
nfontrod
Browse files
Options
Downloads
Patches
Plain Diff
add clone module
parent
ab140d7d
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/clone.rs
+54
-0
54 additions, 0 deletions
src/clone.rs
src/main.rs
+12
-0
12 additions, 0 deletions
src/main.rs
with
66 additions
and
0 deletions
src/clone.rs
0 → 100644
+
54
−
0
View file @
9beee746
use
std
::
path
::
PathBuf
;
use
std
::
process
::
exit
;
use
colored
::
Colorize
;
use
crate
::
configt
;
use
crate
::
init
;
use
crate
::
push
;
fn
check_remote_dir
(
url
:
&
PathBuf
,
adress
:
&
str
)
{
if
!
push
::
check_dir_exist
(
url
,
adress
)
{
eprintln!
(
"{}: {} no such directory"
,
"error"
.red
(),
url
.display
());
exit
(
1
);
}
let
v
=
vec!
[
"data"
,
"config"
,
"archive_list"
];
for
file
in
v
{
let
mut
path
=
url
.clone
();
path
.push
(
file
);
let
exists
=
match
file
{
"data"
=>
push
::
check_dir_exist
(
&
path
,
adress
),
_
=>
push
::
check_file_exist
(
&
path
,
adress
),
};
if
!
exists
{
let
kind
=
if
file
==
"data"
{
"folder"
}
else
{
"file"
};
eprintln!
(
"{}: no {} {} inside {} directory"
,
"error"
.red
(),
file
,
kind
,
url
.display
()
);
exit
(
1
);
}
}
}
/// Create a push the tar achive on the selected remote path
/// # Arguments
/// - `remote`: The name of a remote
pub
fn
clone
(
path
:
&
str
)
->
()
{
let
(
adress
,
url
)
=
push
::
split_path
(
path
);
let
(
borg_path
,
_
)
=
init
::
get_borg_folder
();
if
borg_path
.is_dir
()
{
eprintln!
(
"{}: {} already exits."
,
"error"
.red
(),
&
borg_path
.display
());
exit
(
1
);
}
let
borg_folder
=
borg_path
.canonicalize
()
.unwrap
();
check_remote_dir
(
&
url
,
&
adress
);
push
::
copy_file
(
&
borg_folder
,
&
url
,
&
adress
,
"pull"
);
let
name
=
url
.file_name
()
.unwrap
()
.to_str
()
.unwrap
();
configt
::
create_named_local_config
(
name
);
let
gitignore
=
init
::
get_gitignore_file
();
init
::
update_gitignore
(
&
gitignore
);
}
This diff is collapsed.
Click to expand it.
src/main.rs
+
12
−
0
View file @
9beee746
...
@@ -6,6 +6,7 @@ use colored::Colorize;
...
@@ -6,6 +6,7 @@ use colored::Colorize;
use
configt
::
PartialPrune
;
use
configt
::
PartialPrune
;
mod
checkout
;
mod
checkout
;
mod
clean
;
mod
clean
;
mod
clone
;
mod
commit
;
mod
commit
;
mod
compact
;
mod
compact
;
mod
config_structure
;
mod
config_structure
;
...
@@ -123,6 +124,8 @@ enum Commands {
...
@@ -123,6 +124,8 @@ enum Commands {
/// The purpose of this command is to be used if a pull command fails after
/// The purpose of this command is to be used if a pull command fails after
/// removing content inside the .borg folder
/// removing content inside the .borg folder
Restore
,
Restore
,
/// Clones a repository given a destination
Clone
(
Clone
),
}
}
#[derive(Debug,
Args)]
#[derive(Debug,
Args)]
...
@@ -329,6 +332,12 @@ struct Pull {
...
@@ -329,6 +332,12 @@ struct Pull {
key
:
String
,
key
:
String
,
}
}
#[derive(Debug,
Args)]
struct
Clone
{
/// The path pointing to a borg folder
path
:
String
,
}
fn
main
()
{
fn
main
()
{
let
args
=
Cli
::
parse
();
let
args
=
Cli
::
parse
();
...
@@ -421,5 +430,8 @@ fn main() {
...
@@ -421,5 +430,8 @@ fn main() {
Commands
::
Restore
=>
{
Commands
::
Restore
=>
{
restore
::
restore
();
restore
::
restore
();
}
}
Commands
::
Clone
(
c
)
=>
{
clone
::
clone
(
&
c
.path
);
}
}
}
}
}
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