diff --git a/docs/reference.md b/docs/reference.md index d0d4744..5432ed3 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -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 @@ -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 @@ -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" @@ -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 diff --git a/docs/use_cases.md b/docs/use_cases.md index 536a1b6..cd252bd 100644 --- a/docs/use_cases.md +++ b/docs/use_cases.md @@ -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 diff --git a/src/config.rs b/src/config.rs index 2ff829d..853ed85 100644 --- a/src/config.rs +++ b/src/config.rs @@ -322,6 +322,8 @@ pub struct Project { depends: HashMap, changelog: Option, version: Location, + #[serde(default)] + also: Vec, #[serde(default, deserialize_with = "deser_labels")] labels: Vec, tag_prefix: Option, @@ -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)?; @@ -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, @@ -720,6 +731,8 @@ fn expand_version(version: &Location, sub: &SubExtent) -> Location { } } +fn expand_also(also: &[Location]) -> Vec { also.iter().filter(|l| !l.is_tags()).cloned().collect() } + struct SubExtent { dir: Option, majors: Vec, @@ -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(), @@ -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(), @@ -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(),