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
b5bcc552
Verified
Commit
b5bcc552
authored
Feb 1, 2023
by
nfontrod
Browse files
Options
Downloads
Patches
Plain Diff
src/configt.rs: add gblk_project_name section in config
parent
c3a0e78f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/configt.rs
+39
-7
39 additions, 7 deletions
src/configt.rs
with
39 additions
and
7 deletions
src/configt.rs
+
39
−
7
View file @
b5bcc552
...
@@ -77,12 +77,12 @@ pub fn get_global_config() -> Option<PathBuf> {
...
@@ -77,12 +77,12 @@ pub fn get_global_config() -> Option<PathBuf> {
/// only the local one
/// only the local one
/// # Return
/// # Return
/// The path containing the local of global configuration
/// The path containing the local of global configuration
fn
get_config
(
global
:
bool
)
->
PathBuf
{
pub
(
crate
)
fn
get_config
(
global
:
bool
)
->
PathBuf
{
if
global
{
if
global
{
match
get_global_config
()
{
match
get_global_config
()
{
Some
(
path
)
=>
path
,
Some
(
path
)
=>
path
,
None
=>
{
None
=>
{
println!
(
"{} config not found !"
,
"global"
.red
());
e
println!
(
"{} config not found !"
,
"global"
.red
());
exit
(
0
);
exit
(
0
);
}
}
}
}
...
@@ -90,7 +90,7 @@ fn get_config(global: bool) -> PathBuf {
...
@@ -90,7 +90,7 @@ fn get_config(global: bool) -> PathBuf {
match
get_borgconfig
()
{
match
get_borgconfig
()
{
Some
(
path
)
=>
path
,
Some
(
path
)
=>
path
,
None
=>
{
None
=>
{
println!
(
"{} config not found !"
,
"local"
.
yellow
());
e
println!
(
"{} config not found !"
,
"local"
.
red
());
exit
(
0
);
exit
(
0
);
}
}
}
}
...
@@ -117,12 +117,18 @@ pub fn parse_toml(global: bool) -> Config {
...
@@ -117,12 +117,18 @@ pub fn parse_toml(global: bool) -> Config {
Ok
(
s
)
=>
s
,
Ok
(
s
)
=>
s
,
};
};
if
content
.is_empty
()
{
if
content
.is_empty
()
{
return
Config
{
if
global
{
gblk_prune
:
None
,
return
Config
::
new
(
global
);
gblk_remote
:
None
,
}
else
{
};
eprintln!
(
"{}: Loccal config file should not be empty !"
,
"error"
.red
()
);
exit
(
1
);
}
}
}
let
config_str
:
Config
=
toml
::
from_str
(
&
content
)
.unwrap
();
let
config_str
:
Config
=
toml
::
from_str
(
&
content
)
.unwrap
();
config_str
.check_project_type
(
global
,
&
config_file
);
config_str
config_str
}
}
...
@@ -346,6 +352,20 @@ pub fn write_config(config: &Config, global: bool) {
...
@@ -346,6 +352,20 @@ pub fn write_config(config: &Config, global: bool) {
};
};
}
}
/// Create a local config file
pub
fn
create_local_config
()
{
let
conf
=
Config
::
new
(
false
);
write_config
(
&
conf
,
false
);
}
/// Create a named local config file
/// # Arguments
/// - `name`: The name of the config file
pub
fn
create_named_local_config
(
name
:
&
str
)
{
let
conf
=
Config
::
new_named
(
name
);
write_config
(
&
conf
,
false
);
}
/// Function that update the current gblk config file for the project folder
/// Function that update the current gblk config file for the project folder
/// # Arguments
/// # Arguments
/// - `key` : The key to update
/// - `key` : The key to update
...
@@ -404,6 +424,18 @@ pub fn remove_config(key: &str, global: bool) -> () {
...
@@ -404,6 +424,18 @@ pub fn remove_config(key: &str, global: bool) -> () {
};
};
}
}
/// Get the name of the current project
pub
(
crate
)
fn
get_project_name
()
->
String
{
let
config
=
parse_toml
(
false
);
match
config
.get_name
()
{
None
=>
{
eprintln!
(
"{}: Unable to get the project name !"
,
"error"
.red
());
exit
(
1
);
}
Some
(
name
)
=>
name
,
}
}
/// Function that recover the local or global gblk config
/// Function that recover the local or global gblk config
/// # Description
/// # Description
/// This function return the parsed local gblk config file if it exists. If
/// This function return the parsed local gblk config file if it exists. If
...
...
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