Skip to content

Commit

Permalink
fix: prefer --authdate over patch time with author
Browse files Browse the repository at this point in the history
fixes #457

Signed-off-by: kyle merfeld <kmerfeld1@gmail.com>
  • Loading branch information
kmerfeld authored and jpgrayson committed Jun 16, 2024
1 parent 10d816e commit 5b0defa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/patch/edit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,10 +594,10 @@ fn author_from_args(
matches: &clap::ArgMatches,
time: Option<gix::date::Time>,
) -> Result<Option<gix::actor::Signature>> {
let time = if let Some(time) = time {
time
} else if let Some(authdate) = matches.get_one::<gix::date::Time>("authdate").copied() {
let time = if let Some(authdate) = matches.get_one::<gix::date::Time>("authdate").copied() {
authdate
} else if let Some(time) = time {
time
} else {
return Ok(None);
};
Expand Down
6 changes: 6 additions & 0 deletions t/t3300-edit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,12 @@ test_expect_success 'Fail to set invalid author date' '
test "$(adate HEAD)" = "2013-01-28 22:30:00 -0300"
'

test_expect_success 'Set author date and author' '
stg edit p2 --authdate "2000-01-28 22:30:00 -0300" --author "Elizabeth Bennet <ebennet@example.com>" &&
test "$(adate HEAD)" = "2000-01-28 22:30:00 -0300" &&
test "$(auth HEAD)" = "Elizabeth Bennet, ebennet@example.com"
'

test_expect_success 'Set author date to "now"' '
before=$(date "+%F %T %z") &&
stg edit p2 --authdate now &&
Expand Down

0 comments on commit 5b0defa

Please sign in to comment.