-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #502 --------- Co-authored-by: Dylan Anthony <[email protected]>
- Loading branch information
Showing
83 changed files
with
695 additions
and
274 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
.changeset/use_the_correct_tags_for_gomod_files_in_subdirectories.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
default: patch | ||
--- | ||
|
||
#### Use the correct tags for `go.mod` files in subdirectories | ||
|
||
PR #544 fixed issue #502 by @BatmanAoD. | ||
|
||
Previously, the version for a `go.mod` file was determined by the package tag, named `v{Version}` for single packages or `{PackageName}/v{Version}` for named packages. This worked when the `go.mod` file was in the root of the repository or a directory named `{PackageName}` (respectively), but not when it was in a different directory. Now, the version tag, both for determining the current version and creating a new release, will correctly be determined by the name of the directory the `go.mod` file is in (relative to the working directory). The existing package tagging strategy remains unchanged. | ||
|
||
For example, consider this `knope.toml` file: | ||
|
||
```toml | ||
[package] | ||
versioned_files = ["some_dir/go.mod"] | ||
``` | ||
|
||
Previous to this release, creating the version `1.2.3` would only create a tag `v1.2.3`. Now, it will _additionally_ create the tag `some_dir/v1.2.3`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
//! Proxies to FS utils that _either_ actually write to files or print to stdout (for dry runs). | ||
use std::{ | ||
fmt::Display, | ||
io, | ||
io::Write, | ||
path::{Path, PathBuf}, | ||
}; | ||
|
||
use log::trace; | ||
use miette::Diagnostic; | ||
use thiserror::Error; | ||
|
||
/// Writes to a file if this is not a dry run, or prints just the diff to stdout if it is. | ||
pub(crate) fn write<C: AsRef<[u8]> + Display>( | ||
dry_run: &mut Option<Box<dyn Write>>, | ||
diff: &str, | ||
path: &Path, | ||
contents: C, | ||
) -> Result<(), Error> { | ||
if let Some(stdout) = dry_run { | ||
writeln!(stdout, "Would write {} to {}", diff, path.display()).map_err(Error::Stdout) | ||
} else { | ||
trace!("Writing {} to {}", contents, path.display()); | ||
std::fs::write(path, contents).map_err(|source| Error::File { | ||
path: path.into(), | ||
source, | ||
}) | ||
} | ||
} | ||
|
||
#[derive(Debug, Diagnostic, Error)] | ||
pub(crate) enum Error { | ||
#[error("Error writing to {path}: {source}")] | ||
File { | ||
path: PathBuf, | ||
#[source] | ||
source: io::Error, | ||
}, | ||
#[error("Error writing to stdout: {0}")] | ||
Stdout(#[from] io::Error), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ use crate::{ | |
mod app_config; | ||
mod command; | ||
mod config; | ||
mod fs; | ||
mod git; | ||
mod issues; | ||
mod prompt; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.