Skip to content

Commit a7360db

Browse files
feat(record)!: use default commit message for --stash
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.
1 parent 2cb8484 commit a7360db

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
## [Unreleased] - ReleaseDate
1111

12+
### Changed
13+
14+
- BREAKING (#1462): `record --stash` now uses a default message if none are given, instead of prompting for one.
15+
1216
## [v0.10.0] - 2024-10-10
1317

1418
### Added

git-branchless-record/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ fn record(
157157
)?);
158158
}
159159
} else {
160+
let messages = if messages.is_empty() && stash {
161+
vec!["temp: stash".to_string()]
162+
} else {
163+
messages
164+
};
160165
let args = {
161166
let mut args = vec!["commit"];
162167
args.extend(messages.iter().flat_map(|message| ["--message", message]));

git-branchless-record/tests/test_record.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,40 @@ fn test_record_stash() -> eyre::Result<()> {
342342
Ok(())
343343
}
344344

345+
#[test]
346+
fn test_record_stash_default_message() -> eyre::Result<()> {
347+
let git = make_git()?;
348+
349+
if !git.supports_reference_transactions()? {
350+
return Ok(());
351+
}
352+
git.init_repo()?;
353+
354+
git.commit_file("test1", 1)?;
355+
git.write_file_txt("test1", "new test1 contents\n")?;
356+
{
357+
let (stdout, _stderr) = git.branchless("record", &["--stash"])?;
358+
insta::assert_snapshot!(stdout, @r###"
359+
[master 78c965b] temp: stash
360+
1 file changed, 1 insertion(+), 1 deletion(-)
361+
branchless: running command: <git-executable> branch -f master 62fc20d2a290daea0d52bdc2ed2ad4be6491010e
362+
branchless: running command: <git-executable> checkout master
363+
"###);
364+
}
365+
366+
{
367+
let stdout = git.smartlog()?;
368+
insta::assert_snapshot!(stdout, @r###"
369+
:
370+
@ 62fc20d (> master) create test1.txt
371+
|
372+
o 78c965b temp: stash
373+
"###);
374+
}
375+
376+
Ok(())
377+
}
378+
345379
#[test]
346380
fn test_record_create_branch() -> eyre::Result<()> {
347381
let git = make_git()?;

0 commit comments

Comments
 (0)