diff --git a/src/patch/edit/mod.rs b/src/patch/edit/mod.rs index 4065ffd8..58a1af6e 100644 --- a/src/patch/edit/mod.rs +++ b/src/patch/edit/mod.rs @@ -594,10 +594,10 @@ fn author_from_args( matches: &clap::ArgMatches, time: Option, ) -> Result> { - let time = if let Some(time) = time { - time - } else if let Some(authdate) = matches.get_one::("authdate").copied() { + let time = if let Some(authdate) = matches.get_one::("authdate").copied() { authdate + } else if let Some(time) = time { + time } else { return Ok(None); }; diff --git a/t/t3300-edit.sh b/t/t3300-edit.sh index 8d06fd11..42063543 100755 --- a/t/t3300-edit.sh +++ b/t/t3300-edit.sh @@ -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 " && + 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 &&