Skip to content

Commit

Permalink
fix: add also, docs
Browse files Browse the repository at this point in the history
  • Loading branch information
chaaz committed Nov 9, 2020
1 parent 3510ef3 commit 12f25d3
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
15 changes: 14 additions & 1 deletion docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ along with their options and flags. You can always use `versio help` or
It will search the repository for projects, and create a new
`.versio.yaml` config based on what it finds. It will also append
`/.versio-paused` to your `.gitignore` file, as a safety measure while
using the `release --pause` command.
using the `release --pause` command. `init` will skip any hidden
directories and files, as well as directories and files listed in
`.gitignore` files.

## Common project types
[Common project types]: #common-project-types
Expand Down Expand Up @@ -240,6 +242,9 @@ projects:
version:
file: "package.json"
json: "version"
also:
- file: "README.md"
pattern: "This is proj_1 version (\d+\.\d+\.\d+)"
hooks:
post_write: ./bin/my_script.sh --auto

Expand All @@ -248,6 +253,12 @@ projects:
root: "proj_2"
tag_prefix: ""
labels: go
depends:
1:
size: match
files:
- file: 'go.mod'
pattern: 'myreg.io/proj_1 v(\d+\.\d+\.\d+)'
version:
tags:
default: "0.0.0"
Expand Down Expand Up @@ -295,6 +306,8 @@ sizes:
created/updated.
- `version`: The location of the project version. See "Version config"
below.
- `also`: Additional locations where the project version should be
written.
- `tag_prefix`: (optional) (required when using version tags) The
prefix to use when reading/writing tags for this project. Not
providing this will result in no tags being written. Using the empty
Expand Down
5 changes: 5 additions & 0 deletions docs/use_cases.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ file with each of those projects listed. If you change later add,
remove, or change the location of your projects, you should edit this
file by hand to keep it up-to-date.

The `init` command will not scan hidden directories or file, or
directories or files listed in any `.gitignore` files. If you want to
include projects in hidden or ignored locations, you'll have to add
those by hand to the resulting `.versio.yaml` file.

## CI/CD

### GitHub Action Matrixes
Expand Down
16 changes: 16 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ pub struct Project {
depends: HashMap<ProjectId, Depends>,
changelog: Option<String>,
version: Location,
#[serde(default)]
also: Vec<Location>,
#[serde(default, deserialize_with = "deser_labels")]
labels: Vec<String>,
tag_prefix: Option<String>,
Expand Down Expand Up @@ -459,9 +461,17 @@ impl Project {

pub fn set_value(&self, write: &mut StateWrite, vers: &str) -> Result<()> {
self.version.write_value(write, self.root(), vers, &self.id)?;
self.set_also(write, vers)?;
self.forward_tag(write, vers)
}

fn set_also(&self, write: &mut StateWrite, vers: &str) -> Result<()> {
for loc in &self.also {
loc.write_value(write, self.root(), vers, &self.id)?;
}
Ok(())
}

pub fn forward_tag(&self, write: &mut StateWrite, vers: &str) -> Result<()> {
if let Some(full_tag) = self.full_version(vers) {
write.tag_head_or_last(vers, full_tag, &self.id)?;
Expand Down Expand Up @@ -502,6 +512,7 @@ impl Project {
depends: expand_depends(&self.depends, &sub),
changelog: self.changelog.clone(),
version: expand_version(&self.version, &sub),
also: expand_also(&self.also),
labels: Default::default(),
tag_prefix: self.tag_prefix.clone(),
subs: None,
Expand Down Expand Up @@ -720,6 +731,8 @@ fn expand_version(version: &Location, sub: &SubExtent) -> Location {
}
}

fn expand_also(also: &[Location]) -> Vec<Location> { also.iter().filter(|l| !l.is_tags()).cloned().collect() }

struct SubExtent {
dir: Option<String>,
majors: Vec<u32>,
Expand Down Expand Up @@ -1487,6 +1500,7 @@ sizes:
picker: Picker::Json(ScanningPicker::new(vec![Part::Map("version".into())])),
format: None
}),
also: Vec::new(),
tag_prefix: None,
labels: Default::default(),
hooks: Default::default(),
Expand All @@ -1512,6 +1526,7 @@ sizes:
picker: Picker::Json(ScanningPicker::new(vec![Part::Map("version".into())])),
format: None
}),
also: Vec::new(),
tag_prefix: None,
labels: Default::default(),
hooks: Default::default(),
Expand All @@ -1536,6 +1551,7 @@ sizes:
picker: Picker::Json(ScanningPicker::new(vec![Part::Map("version".into())])),
format: None
}),
also: Vec::new(),
tag_prefix: None,
labels: Default::default(),
hooks: Default::default(),
Expand Down

0 comments on commit 12f25d3

Please sign in to comment.