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
50f2aea2
Verified
Commit
50f2aea2
authored
Jan 13, 2023
by
nfontrod
Browse files
Options
Downloads
Patches
Plain Diff
src/configt.rs: delete repositoy param and regex changes on it
parent
cf44f823
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/configt.rs
+7
-16
7 additions, 16 deletions
src/configt.rs
with
7 additions
and
16 deletions
src/configt.rs
+
7
−
16
View file @
50f2aea2
...
@@ -4,7 +4,6 @@ use crate::prune::{new_prune, prune_launcher};
...
@@ -4,7 +4,6 @@ use crate::prune::{new_prune, prune_launcher};
use
clap
::
Args
;
use
clap
::
Args
;
use
colored
::
Colorize
;
use
colored
::
Colorize
;
use
home
;
use
home
;
use
regex
::
Regex
;
use
std
::{
path
::
PathBuf
,
process
::
exit
};
use
std
::{
path
::
PathBuf
,
process
::
exit
};
use
toml
;
use
toml
;
...
@@ -53,10 +52,7 @@ pub(crate) struct PartialPrune {
...
@@ -53,10 +52,7 @@ pub(crate) struct PartialPrune {
/// current project
/// current project
pub
fn
get_borgconfig
()
->
Option
<
PathBuf
>
{
pub
fn
get_borgconfig
()
->
Option
<
PathBuf
>
{
let
(
mut
config_path
,
_
)
=
commit
::
check_path
();
let
(
mut
config_path
,
_
)
=
commit
::
check_path
();
config_path
.push
(
"config"
);
config_path
.push
(
".gblkconfig"
);
if
!
config_path
.is_file
()
{
return
None
;
}
Some
(
config_path
)
Some
(
config_path
)
}
}
...
@@ -86,16 +82,16 @@ fn get_config(global: bool) -> PathBuf {
...
@@ -86,16 +82,16 @@ fn get_config(global: bool) -> PathBuf {
match
get_global_config
()
{
match
get_global_config
()
{
Some
(
path
)
=>
path
,
Some
(
path
)
=>
path
,
None
=>
{
None
=>
{
e
println!
(
"
local
config not found !"
);
println!
(
"
{}
config not found !"
,
"global"
.red
()
);
exit
(
1
);
exit
(
0
);
}
}
}
}
}
else
{
}
else
{
match
get_borgconfig
()
{
match
get_borgconfig
()
{
Some
(
path
)
=>
path
,
Some
(
path
)
=>
path
,
None
=>
{
None
=>
{
e
println!
(
"
global
config not found !"
);
println!
(
"
{}
config not found !"
,
"local"
.yellow
()
);
exit
(
1
);
exit
(
0
);
}
}
}
}
}
}
...
@@ -122,14 +118,11 @@ pub fn parse_toml(global: bool) -> Config {
...
@@ -122,14 +118,11 @@ pub fn parse_toml(global: bool) -> Config {
};
};
if
content
.is_empty
()
{
if
content
.is_empty
()
{
return
Config
{
return
Config
{
repository
:
None
,
gblk_prune
:
None
,
gblk_prune
:
None
,
gblk_remote
:
None
,
gblk_remote
:
None
,
};
};
}
}
let
re
=
Regex
::
new
(
"id = (?P<first>[0-9a-z]+)
\\
W"
)
.unwrap
();
let
config_str
:
Config
=
toml
::
from_str
(
&
content
)
.unwrap
();
let
nc
=
re
.replace
(
&
content
,
"id = '$first'"
);
let
config_str
:
Config
=
toml
::
from_str
(
&
nc
)
.unwrap
();
config_str
config_str
}
}
...
@@ -325,9 +318,7 @@ fn get_gblkconfig(full_config: &Config) -> GblkConfig {
...
@@ -325,9 +318,7 @@ fn get_gblkconfig(full_config: &Config) -> GblkConfig {
/// The string corresponding to toml file
/// The string corresponding to toml file
fn
toml_to_string
(
config
:
&
Config
)
->
String
{
fn
toml_to_string
(
config
:
&
Config
)
->
String
{
let
gblk_str
=
toml
::
to_string_pretty
(
&
config
)
.unwrap
();
let
gblk_str
=
toml
::
to_string_pretty
(
&
config
)
.unwrap
();
let
re
=
Regex
::
new
(
"id = '(?P<first>[0-9a-z]+)'"
)
.unwrap
();
gblk_str
let
nc
=
re
.replace
(
&
gblk_str
,
"id = $first"
)
.to_string
();
nc
}
}
/// Function used to write a configuration file
/// Function used to write a configuration file
...
...
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