Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
kurzlink
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Dominik Riemer
kurzlink
Commits
adb6ae42
Commit
adb6ae42
authored
4 months ago
by
Evy Storozhenko
Browse files
Options
Downloads
Patches
Plain Diff
fixed relative paths
parent
697f5986
Branches
main
No related tags found
No related merge requests found
Pipeline
#253759
passed
3 months ago
Stage: build
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/config/mod.rs
+24
-9
24 additions, 9 deletions
src/config/mod.rs
with
24 additions
and
9 deletions
src/config/mod.rs
+
24
−
9
View file @
adb6ae42
use
anyhow
::
Context
;
use
minijinja
::
Environment
;
use
std
::{
collections
::
HashMap
,
fs
,
path
::
Path
};
use
std
::{
collections
::
HashMap
,
fs
,
path
::{
Path
,
PathBuf
},
};
use
serde
::{
Deserialize
,
Serialize
};
use
serde_json
::
json
;
...
...
@@ -33,15 +37,26 @@ pub struct Config {
impl
Config
{
pub
fn
new
(
config_path
:
impl
AsRef
<
Path
>
)
->
anyhow
::
Result
<
Self
>
{
let
mut
config
:
Config
=
serde_yaml
::
from_str
(
&
fs
::
read_to_string
(
config_path
)
.with_context
(||
"config not found"
.to_string
())
?
,
&
fs
::
read_to_string
(
&
config_path
)
.with_context
(||
"config not found"
.to_string
())
?
,
)
?
;
let
additional_files
=
config
.files
.clone
()
.unwrap_or_default
();
for
file
in
additional_files
{
let
mut
additional_links
:
Vec
<
Shortlink
>
=
serde_yaml
::
from_str
(
&
fs
::
read_to_string
(
file
)
.with_context
(||
"additional shortlink file not found"
.to_string
())
?
,
)
?
;
config
.shortlinks
.append
(
&
mut
additional_links
);
if
let
Some
(
ref
additional_paths
)
=
config
.files
{
let
base_path
=
config_path
.as_ref
()
.parent
()
.unwrap
();
let
actual_paths
:
Vec
<
PathBuf
>
=
additional_paths
.iter
()
.map
(|
path_str
|
{
let
path
=
PathBuf
::
from
(
&
path_str
);
if
path
.is_absolute
()
{
path
}
else
{
base_path
.join
(
path
)
}
})
.collect
();
for
path
in
actual_paths
{
config
.shortlinks
.append
(
&
mut
serde_yaml
::
from_str
(
&
fs
::
read_to_string
(
&
path
)
?
)
?
);
}
}
Ok
(
config
)
}
...
...
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