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
592156bd
"src/git@gitbio.ens-lyon.fr:xgrand/ChIPster.git" did not exist on "1edb0ebd45ec9d4a4bd65192a0d362a425d2a713"
Verified
Commit
592156bd
authored
2 years ago
by
nfontrod
Browse files
Options
Downloads
Patches
Plain Diff
src/init.rs: creation of two gitignores
parent
55a93355
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/init.rs
+22
-14
22 additions, 14 deletions
src/init.rs
with
22 additions
and
14 deletions
src/init.rs
+
22
−
14
View file @
592156bd
...
...
@@ -70,21 +70,24 @@ fn init_repository() {
}
}
/// Function that returns the path to the .gitignore file
/// Function that returns the path to the .gitignore
and restuls/.gitignore
file
/// # Return
/// The path to the .gitignore file of the project
pub
(
crate
)
fn
get_gitignore_file
()
->
PathBuf
{
let
(
borg_folder
,
_
)
=
commit
::
check_path
();
/// The path to the .gitignore file
and results/.gitignore
of the project
fn
get_gitignore_file
()
->
(
PathBuf
,
PathBuf
)
{
let
(
borg_folder
,
results
)
=
commit
::
check_path
();
let
borg_folder
=
borg_folder
.canonicalize
()
.unwrap
();
let
mut
results
=
results
.canonicalize
()
.unwrap
();
let
mut
gitignore
=
borg_folder
.parent
()
.unwrap
()
.to_path_buf
();
gitignore
.push
(
".gitignore"
);
gitignore
results
.push
(
".gitignore"
);
(
gitignore
,
results
)
}
/// This function update the .gitignore file with folder created by gblk
/// # Arguments
/// - ` gitignore_file` : Path to the gitignore file
pub
(
crate
)
fn
update_gitignore
(
gitignore_file
:
&
PathBuf
)
->
()
{
/// - `ignore`: The string to add in gitignore file
fn
update_gitignore
(
gitignore_file
:
&
PathBuf
,
ignore
:
&
str
)
->
()
{
if
!
gitignore_file
.is_file
()
{
std
::
fs
::
File
::
create
(
gitignore_file
)
.expect
(
&
format!
(
"{}: Unable to create {} file"
,
...
...
@@ -100,12 +103,18 @@ pub(crate) fn update_gitignore(gitignore_file: &PathBuf) -> () {
"error"
.red
(),
&
gitignore_file
.display
()
));
giti
.write_all
(
"results/*
\n
!results/.gitignore
\n
.borg
\n
.mount
\n
.tmp
\n
"
.as_bytes
())
.expect
(
&
format!
(
"{}: Unable to write {} file"
,
"error"
.red
(),
&
gitignore_file
.display
()
));
giti
.write_all
(
ignore
.as_bytes
())
.expect
(
&
format!
(
"{}: Unable to write {} file"
,
"error"
.red
(),
&
gitignore_file
.display
()
));
}
/// Update .gitignore and results/.gitignore
pub
(
crate
)
fn
update_gitignores
()
{
let
(
gitignore
,
giti_res
)
=
get_gitignore_file
();
update_gitignore
(
&
gitignore
,
".borg
\n
.mount
\n
.tmp
\n
"
);
update_gitignore
(
&
giti_res
,
"*
\n
!.gitignore"
);
}
/// Creation of a borg repository and creation of hooks if needed inside `.git/hooks`
...
...
@@ -117,8 +126,7 @@ pub(crate) fn update_gitignore(gitignore_file: &PathBuf) -> () {
pub
fn
init_and_hook
(
hooks
:
bool
,
compression
:
&
str
,
mode
:
&
str
)
{
init_repository
();
configt
::
create_local_config
();
let
gitignore
=
get_gitignore_file
();
update_gitignore
(
&
gitignore
);
update_gitignores
();
if
hooks
{
create_hooks
::
create_hooks
(
compression
,
mode
);
}
...
...
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