Skip to content

Commit

Permalink
feat(record)!: use default commit message for --stash
Browse files Browse the repository at this point in the history
But only when no message is explicitly supplied.

This is a breaking change. Previously, the user would be prompted for a message
if none was supplied.
  • Loading branch information
claytonrcarter committed Dec 10, 2024
1 parent 2cb8484 commit a7360db
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased] - ReleaseDate

### Changed

- BREAKING (#1462): `record --stash` now uses a default message if none are given, instead of prompting for one.

## [v0.10.0] - 2024-10-10

### Added
Expand Down
5 changes: 5 additions & 0 deletions git-branchless-record/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ fn record(
)?);
}
} else {
let messages = if messages.is_empty() && stash {
vec!["temp: stash".to_string()]
} else {
messages
};
let args = {
let mut args = vec!["commit"];
args.extend(messages.iter().flat_map(|message| ["--message", message]));
Expand Down
34 changes: 34 additions & 0 deletions git-branchless-record/tests/test_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,40 @@ fn test_record_stash() -> eyre::Result<()> {
Ok(())
}

#[test]
fn test_record_stash_default_message() -> eyre::Result<()> {
let git = make_git()?;

if !git.supports_reference_transactions()? {
return Ok(());
}
git.init_repo()?;

git.commit_file("test1", 1)?;
git.write_file_txt("test1", "new test1 contents\n")?;
{
let (stdout, _stderr) = git.branchless("record", &["--stash"])?;
insta::assert_snapshot!(stdout, @r###"
[master 78c965b] temp: stash
1 file changed, 1 insertion(+), 1 deletion(-)
branchless: running command: <git-executable> branch -f master 62fc20d2a290daea0d52bdc2ed2ad4be6491010e
branchless: running command: <git-executable> checkout master
"###);
}

{
let stdout = git.smartlog()?;
insta::assert_snapshot!(stdout, @r###"
:
@ 62fc20d (> master) create test1.txt
|
o 78c965b temp: stash
"###);
}

Ok(())
}

#[test]
fn test_record_create_branch() -> eyre::Result<()> {
let git = make_git()?;
Expand Down

0 comments on commit a7360db

Please sign in to comment.