-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor configuration management package #16
base: main
Are you sure you want to change the base?
Refactor configuration management package #16
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also discuss at 10:00 as there's a lot in the PR :) Bravo Guillaume
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello Guillaume. As stated earlier in MM, the context implementation is too static and not extensible. It must be refactored. Can you please take a look at the tiny crate I quickly implemented here. Thanks a lot.
where | ||
R: GitRepository, | ||
{ | ||
pub map: HashMap<String, Value>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment on public members
/// The context structure used to share datas between crates. | ||
/// | ||
/// The used repository should implements the [GitRepository] trait as Sleppa works only with git. | ||
pub struct Context<R> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More readable if the context module is implemented in its own context.rs
file.
|
||
## How it works | ||
These `commits` are given to the `sleppa_commit_analyzer` which will analyze their message. In order to proceed, a configuration file that defines the release rules is loaded. | ||
The crate determines the new release action type to apply. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit analyzer aims at determining the new release action type to apply, namely a [Minor] , [Major] or [Patch] action.
Description
This pull request aims at refactoring the configuration crate to be more generic. The configuration crate is, nowadays, reading a configuration file to retrieve the given
release rules
. However, we want this configuration to be more generic and load all the data and/or file needed by the crates.We decided that each crate that needs file and/or data must implement its own configuration.
Three structures need to be created :
Context
with a fieldmap
which is aHashMap<String, Value>
.Configuration
with a fieldmap
wich is aHashMap<String, Value>
, where the key defines the data to access.Value
which represents all possible value a data could be. Therefore, a method to access the value is also required likeas_string()
,as_commits()
, etc.The crate that needs to access
Context
are :sleppa_commit_analyzer
: it needs acces to the list of commits and an optional toml file to read therelease rules
and apply them.sleppa_changelog
: it needs a logged user to commit theCHANGELOG.md
into the repository, the repository, the last tag and new tag and the list of commits. An optional changlof file path can be provided by the user and then loaded.sleppa_code_archiver
: it needs a logged user to publish the release into the repositorysleppa_versioner
: it needs the last tag and the release action type.The
Context
implements method to retrieve theseValue
s.Related issues
closes #10
How has this been tested?
The crates contain unit tests in the file
tests.rs
.Test configuration:
Rust cargo test
Checklist: