From 9591cc381a2d065781e6b45fb52ef2ee6aa29d20 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sun, 8 May 2022 21:05:01 +1000 Subject: [PATCH] support setting the author of a commit update copy --- pkg/commands/git_commands/commit.go | 6 ++ pkg/commands/git_commands/rebase.go | 18 +++++- .../controllers/helpers/suggestions_helper.go | 9 +++ .../controllers/local_commits_controller.go | 55 ++++++++++++++---- pkg/i18n/english.go | 4 ++ .../expected/repo/.git_keep/COMMIT_EDITMSG | 1 + .../expected/repo/.git_keep/FETCH_HEAD | 0 .../setAuthor/expected/repo/.git_keep/HEAD | 1 + .../setAuthor/expected/repo/.git_keep/config | 10 ++++ .../expected/repo/.git_keep/description | 1 + .../setAuthor/expected/repo/.git_keep/index | Bin 0 -> 281 bytes .../expected/repo/.git_keep/info/exclude | 7 +++ .../expected/repo/.git_keep/logs/HEAD | 4 ++ .../repo/.git_keep/logs/refs/heads/master | 4 ++ .../0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 | Bin 0 -> 52 bytes .../18/0cf8328022becee9aaa2577a8f84ea2b9f3827 | Bin 0 -> 21 bytes .../20/75aeb39a2a66a9607860a65b2a71c517760254 | 2 + .../2b/173c861df433fa43ffad13f80c8b312c5c8bce | Bin 0 -> 103 bytes .../87/10ece70b7db9638b9645e93abdbcf210fa4595 | Bin 0 -> 149 bytes .../a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 | Bin 0 -> 21 bytes .../a7/341a59f0ddeef969e69fb6368266d22b0f2416 | Bin 0 -> 77 bytes .../ba/f3189129ba8878ba9b4107eaaaf3389287259b | Bin 0 -> 157 bytes .../d0/1c8bb001458d0a7c01193813685c658e0355ac | Bin 0 -> 150 bytes .../df/6b0d2bcc76e6ec0fca20c227104a4f28bac41b | Bin 0 -> 21 bytes .../expected/repo/.git_keep/refs/heads/master | 1 + .../setAuthor/expected/repo/myfile1 | 1 + .../setAuthor/expected/repo/myfile2 | 1 + .../setAuthor/expected/repo/myfile3 | 1 + test/integration/setAuthor/recording.json | 1 + test/integration/setAuthor/setup.sh | 24 ++++++++ test/integration/setAuthor/test.json | 4 ++ 31 files changed, 141 insertions(+), 14 deletions(-) create mode 100644 test/integration/setAuthor/expected/repo/.git_keep/COMMIT_EDITMSG create mode 100644 test/integration/setAuthor/expected/repo/.git_keep/FETCH_HEAD create mode 100644 test/integration/setAuthor/expected/repo/.git_keep/HEAD create mode 100644 test/integration/setAuthor/expected/repo/.git_keep/config create mode 100644 test/integration/setAuthor/expected/repo/.git_keep/description create mode 100644 test/integration/setAuthor/expected/repo/.git_keep/index create mode 100644 test/integration/setAuthor/expected/repo/.git_keep/info/exclude create mode 100644 test/integration/setAuthor/expected/repo/.git_keep/logs/HEAD create mode 100644 test/integration/setAuthor/expected/repo/.git_keep/logs/refs/heads/master create mode 100644 test/integration/setAuthor/expected/repo/.git_keep/objects/0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 create mode 100644 test/integration/setAuthor/expected/repo/.git_keep/objects/18/0cf8328022becee9aaa2577a8f84ea2b9f3827 create mode 100644 test/integration/setAuthor/expected/repo/.git_keep/objects/20/75aeb39a2a66a9607860a65b2a71c517760254 create mode 100644 test/integration/setAuthor/expected/repo/.git_keep/objects/2b/173c861df433fa43ffad13f80c8b312c5c8bce create mode 100644 test/integration/setAuthor/expected/repo/.git_keep/objects/87/10ece70b7db9638b9645e93abdbcf210fa4595 create mode 100644 test/integration/setAuthor/expected/repo/.git_keep/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5 create mode 100644 test/integration/setAuthor/expected/repo/.git_keep/objects/a7/341a59f0ddeef969e69fb6368266d22b0f2416 create mode 100644 test/integration/setAuthor/expected/repo/.git_keep/objects/ba/f3189129ba8878ba9b4107eaaaf3389287259b create mode 100644 test/integration/setAuthor/expected/repo/.git_keep/objects/d0/1c8bb001458d0a7c01193813685c658e0355ac create mode 100644 test/integration/setAuthor/expected/repo/.git_keep/objects/df/6b0d2bcc76e6ec0fca20c227104a4f28bac41b create mode 100644 test/integration/setAuthor/expected/repo/.git_keep/refs/heads/master create mode 100644 test/integration/setAuthor/expected/repo/myfile1 create mode 100644 test/integration/setAuthor/expected/repo/myfile2 create mode 100644 test/integration/setAuthor/expected/repo/myfile3 create mode 100644 test/integration/setAuthor/recording.json create mode 100644 test/integration/setAuthor/setup.sh create mode 100644 test/integration/setAuthor/test.json diff --git a/pkg/commands/git_commands/commit.go b/pkg/commands/git_commands/commit.go index b876cd02d..444ec17ac 100644 --- a/pkg/commands/git_commands/commit.go +++ b/pkg/commands/git_commands/commit.go @@ -28,6 +28,12 @@ func (self *CommitCommands) ResetAuthor() error { return self.cmd.New("git commit --allow-empty --only --no-edit --amend --reset-author").Run() } +// Sets the commit's author to the supplied value. Value is expected to be of the form 'Name ' +func (self *CommitCommands) SetAuthor(value string) error { + commandStr := fmt.Sprintf("git commit --allow-empty --only --no-edit --amend --author=%s", self.cmd.Quote(value)) + return self.cmd.New(commandStr).Run() +} + // ResetToCommit reset to commit func (self *CommitCommands) ResetToCommit(sha string, strength string, envVars []string) error { return self.cmd.New(fmt.Sprintf("git reset --%s %s", strength, sha)). diff --git a/pkg/commands/git_commands/rebase.go b/pkg/commands/git_commands/rebase.go index d94060f2a..acf1c810b 100644 --- a/pkg/commands/git_commands/rebase.go +++ b/pkg/commands/git_commands/rebase.go @@ -63,9 +63,21 @@ func (self *RebaseCommands) RewordCommitInEditor(commits []*models.Commit, index } func (self *RebaseCommands) ResetCommitAuthor(commits []*models.Commit, index int) error { + return self.GenericAmend(commits, index, func() error { + return self.commit.ResetAuthor() + }) +} + +func (self *RebaseCommands) SetCommitAuthor(commits []*models.Commit, index int, value string) error { + return self.GenericAmend(commits, index, func() error { + return self.commit.SetAuthor(value) + }) +} + +func (self *RebaseCommands) GenericAmend(commits []*models.Commit, index int, f func() error) error { if index == 0 { // we've selected the top commit so no rebase is required - return self.commit.ResetAuthor() + return f() } err := self.BeginInteractiveRebaseForCommit(commits, index) @@ -73,8 +85,8 @@ func (self *RebaseCommands) ResetCommitAuthor(commits []*models.Commit, index in return err } - // now the selected commit should be our head so we'll amend it with the new author - err = self.commit.ResetAuthor() + // now the selected commit should be our head so we'll amend it + err = f() if err != nil { return err } diff --git a/pkg/gui/controllers/helpers/suggestions_helper.go b/pkg/gui/controllers/helpers/suggestions_helper.go index 52ccf9d96..0cc4a642b 100644 --- a/pkg/gui/controllers/helpers/suggestions_helper.go +++ b/pkg/gui/controllers/helpers/suggestions_helper.go @@ -10,6 +10,7 @@ import ( "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/utils" "github.com/jesseduffield/minimal/gitignore" + "github.com/samber/lo" "gopkg.in/ozeidan/fuzzy-patricia.v3/patricia" ) @@ -174,6 +175,14 @@ func (self *SuggestionsHelper) GetRefsSuggestionsFunc() func(string) []*types.Su return FuzzySearchFunc(refNames) } +func (self *SuggestionsHelper) GetAuthorsSuggestionsFunc() func(string) []*types.Suggestion { + authors := lo.Uniq(slices.Map(self.model.Commits, func(commit *models.Commit) string { + return fmt.Sprintf("%s <%s>", commit.AuthorName, commit.AuthorEmail) + })) + + return FuzzySearchFunc(authors) +} + func FuzzySearchFunc(options []string) func(string) []*types.Suggestion { return func(input string) []*types.Suggestion { var matches []string diff --git a/pkg/gui/controllers/local_commits_controller.go b/pkg/gui/controllers/local_commits_controller.go index 7d0f144cd..1d1420a97 100644 --- a/pkg/gui/controllers/local_commits_controller.go +++ b/pkg/gui/controllers/local_commits_controller.go @@ -123,7 +123,7 @@ func (self *LocalCommitsController) GetKeybindings(opts types.KeybindingsOpts) [ }, { Key: opts.GetKey(opts.Config.Commits.ResetCommitAuthor), - Handler: self.checkSelected(self.resetAuthor), + Handler: self.checkSelected(self.amendAttribute), Description: self.c.Tr.LcResetCommitAuthor, }, { @@ -423,17 +423,50 @@ func (self *LocalCommitsController) amendTo(commit *models.Commit) error { }) } -func (self *LocalCommitsController) resetAuthor(commit *models.Commit) error { - return self.c.Confirm(types.ConfirmOpts{ - Title: self.c.Tr.LcResetCommitAuthor, - Prompt: self.c.Tr.SureResetCommitAuthor, - HandleConfirm: func() error { - self.c.LogAction(self.c.Tr.Actions.ResetCommitAuthor) - if err := self.git.Rebase.ResetCommitAuthor(self.model.Commits, self.context().GetSelectedLineIdx()); err != nil { - return self.c.Error(err) - } +func (self *LocalCommitsController) amendAttribute(commit *models.Commit) error { + return self.c.Menu(types.CreateMenuOptions{ + Title: "Amend commit attribute", + Items: []*types.MenuItem{ + { + Label: "reset author", + OnPress: self.resetAuthor, + Key: 'a', + Tooltip: "Reset the commit's author to the currently configured user. This will also renew the author timestamp", + }, + { + Label: "set author", + OnPress: self.setAuthor, + Key: 'A', + Tooltip: "Set the author based on a prompt", + }, + }, + }) +} - return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC}) +func (self *LocalCommitsController) resetAuthor() error { + return self.c.WithWaitingStatus(self.c.Tr.AmendingStatus, func() error { + self.c.LogAction(self.c.Tr.Actions.ResetCommitAuthor) + if err := self.git.Rebase.ResetCommitAuthor(self.model.Commits, self.context().GetSelectedLineIdx()); err != nil { + return self.c.Error(err) + } + + return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC}) + }) +} + +func (self *LocalCommitsController) setAuthor() error { + return self.c.Prompt(types.PromptOpts{ + Title: self.c.Tr.SetAuthorPromptTitle, + FindSuggestionsFunc: self.helpers.Suggestions.GetAuthorsSuggestionsFunc(), + HandleConfirm: func(value string) error { + return self.c.WithWaitingStatus(self.c.Tr.AmendingStatus, func() error { + self.c.LogAction(self.c.Tr.Actions.SetCommitAuthor) + if err := self.git.Rebase.SetCommitAuthor(self.model.Commits, self.context().GetSelectedLineIdx(), value); err != nil { + return self.c.Error(err) + } + + return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC}) + }) }, }) } diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 3eea542c6..975cc9285 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -101,6 +101,7 @@ type TranslationSet struct { LcEditCommit string LcAmendToCommit string LcResetCommitAuthor string + SetAuthorPromptTitle string SureResetCommitAuthor string LcRenameCommitEditor string NoCommitsThisBranch string @@ -537,6 +538,7 @@ type Actions struct { EditCommit string AmendCommit string ResetCommitAuthor string + SetCommitAuthor string RevertCommit string CreateFixupCommit string SquashAllAboveFixupCommits string @@ -725,6 +727,7 @@ func EnglishTranslationSet() TranslationSet { LcEditCommit: "edit commit", LcAmendToCommit: "amend commit with staged changes", LcResetCommitAuthor: "reset commit author", + SetAuthorPromptTitle: "Set author (must look like 'Name ')", SureResetCommitAuthor: "The author field of this commit will be updated to match the configured user. This also renews the author timestamp. Continue?", LcRenameCommitEditor: "reword commit with editor", Error: "Error", @@ -1142,6 +1145,7 @@ func EnglishTranslationSet() TranslationSet { EditCommit: "Edit commit", AmendCommit: "Amend commit", ResetCommitAuthor: "Reset commit author", + SetCommitAuthor: "Set commit author", RevertCommit: "Revert commit", CreateFixupCommit: "Create fixup commit", SquashAllAboveFixupCommits: "Squash all above fixup commits", diff --git a/test/integration/setAuthor/expected/repo/.git_keep/COMMIT_EDITMSG b/test/integration/setAuthor/expected/repo/.git_keep/COMMIT_EDITMSG new file mode 100644 index 000000000..c23aa0355 --- /dev/null +++ b/test/integration/setAuthor/expected/repo/.git_keep/COMMIT_EDITMSG @@ -0,0 +1 @@ +myfile3 diff --git a/test/integration/setAuthor/expected/repo/.git_keep/FETCH_HEAD b/test/integration/setAuthor/expected/repo/.git_keep/FETCH_HEAD new file mode 100644 index 000000000..e69de29bb diff --git a/test/integration/setAuthor/expected/repo/.git_keep/HEAD b/test/integration/setAuthor/expected/repo/.git_keep/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/test/integration/setAuthor/expected/repo/.git_keep/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/test/integration/setAuthor/expected/repo/.git_keep/config b/test/integration/setAuthor/expected/repo/.git_keep/config new file mode 100644 index 000000000..85e571409 --- /dev/null +++ b/test/integration/setAuthor/expected/repo/.git_keep/config @@ -0,0 +1,10 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + ignorecase = true + precomposeunicode = true +[user] + email = Author2@example.com + name = Author2 diff --git a/test/integration/setAuthor/expected/repo/.git_keep/description b/test/integration/setAuthor/expected/repo/.git_keep/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/test/integration/setAuthor/expected/repo/.git_keep/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/test/integration/setAuthor/expected/repo/.git_keep/index b/test/integration/setAuthor/expected/repo/.git_keep/index new file mode 100644 index 0000000000000000000000000000000000000000..78afb6d696aa1597d9382a59dc5c29cd1e57897e GIT binary patch literal 281 zcmZ?q402{*U|<4b=A`l^GZn4x$--zx1_oB9=bz;n7#f!_Ffe`vsu2NVwxxR>|5Z)B z@g*WOiYMRcLV#CG_f-b=+{(1foK!=g0+4>CyuL3m8fuO?x;YX&Ka3ib_MLmVYEgJq zf6FWF`4;LhbBv(os2GLIgUkWZP;I*&F^-3WwAMy! 1652008089 +1000 commit (initial): myfile1 +2075aeb39a2a66a9607860a65b2a71c517760254 d01c8bb001458d0a7c01193813685c658e0355ac Author1 1652008089 +1000 commit: myfile2 +d01c8bb001458d0a7c01193813685c658e0355ac 8710ece70b7db9638b9645e93abdbcf210fa4595 Author2 1652008089 +1000 commit: myfile3 +8710ece70b7db9638b9645e93abdbcf210fa4595 baf3189129ba8878ba9b4107eaaaf3389287259b Author2 1652008097 +1000 commit (amend): myfile3 diff --git a/test/integration/setAuthor/expected/repo/.git_keep/logs/refs/heads/master b/test/integration/setAuthor/expected/repo/.git_keep/logs/refs/heads/master new file mode 100644 index 000000000..38d45fb5d --- /dev/null +++ b/test/integration/setAuthor/expected/repo/.git_keep/logs/refs/heads/master @@ -0,0 +1,4 @@ +0000000000000000000000000000000000000000 2075aeb39a2a66a9607860a65b2a71c517760254 Author1 1652008089 +1000 commit (initial): myfile1 +2075aeb39a2a66a9607860a65b2a71c517760254 d01c8bb001458d0a7c01193813685c658e0355ac Author1 1652008089 +1000 commit: myfile2 +d01c8bb001458d0a7c01193813685c658e0355ac 8710ece70b7db9638b9645e93abdbcf210fa4595 Author2 1652008089 +1000 commit: myfile3 +8710ece70b7db9638b9645e93abdbcf210fa4595 baf3189129ba8878ba9b4107eaaaf3389287259b Author2 1652008097 +1000 commit (amend): myfile3 diff --git a/test/integration/setAuthor/expected/repo/.git_keep/objects/0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 b/test/integration/setAuthor/expected/repo/.git_keep/objects/0e/6cf0a6b79e8d44e186d812a1f74b43d64fac52 new file mode 100644 index 0000000000000000000000000000000000000000..7f2ebf4eeb6ad6875bcc2a2b91ca3345ee06b45e GIT binary patch literal 52 zcmb~ZE#08nZNMgRZ+ literal 0 HcmV?d00001 diff --git a/test/integration/setAuthor/expected/repo/.git_keep/objects/20/75aeb39a2a66a9607860a65b2a71c517760254 b/test/integration/setAuthor/expected/repo/.git_keep/objects/20/75aeb39a2a66a9607860a65b2a71c517760254 new file mode 100644 index 000000000..ce4b3233f --- /dev/null +++ b/test/integration/setAuthor/expected/repo/.git_keep/objects/20/75aeb39a2a66a9607860a65b2a71c517760254 @@ -0,0 +1,2 @@ +xQ +0D)_ݸn%M6Xhz{xfx0ob-em@"ČAq2MF*I#/|N9l\cSҵGT ~+nFȋ5' \ No newline at end of file diff --git a/test/integration/setAuthor/expected/repo/.git_keep/objects/2b/173c861df433fa43ffad13f80c8b312c5c8bce b/test/integration/setAuthor/expected/repo/.git_keep/objects/2b/173c861df433fa43ffad13f80c8b312c5c8bce new file mode 100644 index 0000000000000000000000000000000000000000..0a734f98100d24e67455a3cfa8497adaccc7a422 GIT binary patch literal 103 zcmV-t0GR)H0V^p=O;s>7Fl8__FfcPQQOK=K%gjkNWLUcA@n6-{8($(qqj>V2E(CbB zbYDeLV#FZ9^TVh?Y2Ue*s}_Y<^|!pzo^PR!qQsctem1Z6nX+eZ_)jSuQWx;@*VuJL J8UTCqE3ZN5G4lWb literal 0 HcmV?d00001 diff --git a/test/integration/setAuthor/expected/repo/.git_keep/objects/87/10ece70b7db9638b9645e93abdbcf210fa4595 b/test/integration/setAuthor/expected/repo/.git_keep/objects/87/10ece70b7db9638b9645e93abdbcf210fa4595 new file mode 100644 index 0000000000000000000000000000000000000000..573b0d49cd8d0f4b70fdb25ae5624514250f6685 GIT binary patch literal 149 zcmV;G0BZku0hNwX3c@fDME%Yw@-N74Hc7W2qDM(L8!R-oln8ozgLnbI-pqr6k+s&j zS%?16c2(;p97s4~E}p0)Po<=cR2YOOLMNe9)NE`~^A08nuUMF0Q* literal 0 HcmV?d00001 diff --git a/test/integration/setAuthor/expected/repo/.git_keep/objects/a7/341a59f0ddeef969e69fb6368266d22b0f2416 b/test/integration/setAuthor/expected/repo/.git_keep/objects/a7/341a59f0ddeef969e69fb6368266d22b0f2416 new file mode 100644 index 0000000000000000000000000000000000000000..96d2e71a6af75cdd27ac5d9628a27faecc40fb66 GIT binary patch literal 77 zcmV-T0J8sh0V^p=O;s>AU@$Z=Ff%bx$gNDv%tB=N-?^8o7KK;!x4hDxZ=ntVWIZ01*pecg literal 0 HcmV?d00001 diff --git a/test/integration/setAuthor/expected/repo/.git_keep/objects/ba/f3189129ba8878ba9b4107eaaaf3389287259b b/test/integration/setAuthor/expected/repo/.git_keep/objects/ba/f3189129ba8878ba9b4107eaaaf3389287259b new file mode 100644 index 0000000000000000000000000000000000000000..18a5ff1cd8f2626258d86128a8130da7d84cfdfd GIT binary patch literal 157 zcmV;O0Al}m0d0=K3c@fDL_Oy#au;Mbo3vXH(N9S?8!Q-GN(B9TgS0nKZ)V`Z$Xv=) ztwVpPtEzP)_9Wb4%AP1kPdUeglo^CaLMNe7)GTq;XSE5i^$`Gl-~_Q3KpcpXIu6nW zR-h1~nE0yqd9}A6(4Mz&)psn*Lr*f7i^VQD00tiH5dpxowcV?_i*6U)e{twH(Ueb~ L9!lm5T1G-h2^2;m literal 0 HcmV?d00001 diff --git a/test/integration/setAuthor/expected/repo/.git_keep/objects/d0/1c8bb001458d0a7c01193813685c658e0355ac b/test/integration/setAuthor/expected/repo/.git_keep/objects/d0/1c8bb001458d0a7c01193813685c658e0355ac new file mode 100644 index 0000000000000000000000000000000000000000..e9d69bf0f4b5a5683960c3cf75fcf12c31964290 GIT binary patch literal 150 zcmV;H0BQet0hNwH3c@fDMP26<*$Xl=O(qG5=usx^1PhHVC4%1GAYQ=Le>`~b$FOp|I!oRm|^Ja8oDi6}!Mhio?4_0dBJUNjF$NSGxtgvcQ5GfBYF zV+ai7osnm|ue-f{2krR>SA9v{7Cnt?y;x*V01;xcM+5-VZNJy_@6gnDnHMGV0pct{ EedY5)kN^Mx literal 0 HcmV?d00001 diff --git a/test/integration/setAuthor/expected/repo/.git_keep/objects/df/6b0d2bcc76e6ec0fca20c227104a4f28bac41b b/test/integration/setAuthor/expected/repo/.git_keep/objects/df/6b0d2bcc76e6ec0fca20c227104a4f28bac41b new file mode 100644 index 0000000000000000000000000000000000000000..9b771fc2f6f41f91b00976b4ff3f8f9935f7931e GIT binary patch literal 21 ccmb>`CU&08otwO#lD@ literal 0 HcmV?d00001 diff --git a/test/integration/setAuthor/expected/repo/.git_keep/refs/heads/master b/test/integration/setAuthor/expected/repo/.git_keep/refs/heads/master new file mode 100644 index 000000000..2499d7343 --- /dev/null +++ b/test/integration/setAuthor/expected/repo/.git_keep/refs/heads/master @@ -0,0 +1 @@ +baf3189129ba8878ba9b4107eaaaf3389287259b diff --git a/test/integration/setAuthor/expected/repo/myfile1 b/test/integration/setAuthor/expected/repo/myfile1 new file mode 100644 index 000000000..a5bce3fd2 --- /dev/null +++ b/test/integration/setAuthor/expected/repo/myfile1 @@ -0,0 +1 @@ +test1 diff --git a/test/integration/setAuthor/expected/repo/myfile2 b/test/integration/setAuthor/expected/repo/myfile2 new file mode 100644 index 000000000..180cf8328 --- /dev/null +++ b/test/integration/setAuthor/expected/repo/myfile2 @@ -0,0 +1 @@ +test2 diff --git a/test/integration/setAuthor/expected/repo/myfile3 b/test/integration/setAuthor/expected/repo/myfile3 new file mode 100644 index 000000000..df6b0d2bc --- /dev/null +++ b/test/integration/setAuthor/expected/repo/myfile3 @@ -0,0 +1 @@ +test3 diff --git a/test/integration/setAuthor/recording.json b/test/integration/setAuthor/recording.json new file mode 100644 index 000000000..9084af754 --- /dev/null +++ b/test/integration/setAuthor/recording.json @@ -0,0 +1 @@ +{"KeyEvents":[{"Timestamp":1118,"Mod":0,"Key":259,"Ch":0},{"Timestamp":1382,"Mod":0,"Key":259,"Ch":0},{"Timestamp":2654,"Mod":0,"Key":256,"Ch":97},{"Timestamp":3632,"Mod":0,"Key":258,"Ch":0},{"Timestamp":4070,"Mod":0,"Key":13,"Ch":13},{"Timestamp":6702,"Mod":0,"Key":9,"Ch":9},{"Timestamp":7486,"Mod":0,"Key":258,"Ch":0},{"Timestamp":7899,"Mod":0,"Key":13,"Ch":13},{"Timestamp":9141,"Mod":0,"Key":256,"Ch":113}],"ResizeEvents":[{"Timestamp":0,"Width":272,"Height":74}]} \ No newline at end of file diff --git a/test/integration/setAuthor/setup.sh b/test/integration/setAuthor/setup.sh new file mode 100644 index 000000000..2eeb4d549 --- /dev/null +++ b/test/integration/setAuthor/setup.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +set -e + +cd $1 + +git init + +git config user.email "Author1@example.com" +git config user.name "Author1" + +echo test1 > myfile1 +git add . +git commit -am "myfile1" +echo test2 > myfile2 +git add . +git commit -am "myfile2" + +git config user.email "Author2@example.com" +git config user.name "Author2" + +echo test3 > myfile3 +git add . +git commit -am "myfile3" diff --git a/test/integration/setAuthor/test.json b/test/integration/setAuthor/test.json new file mode 100644 index 000000000..c8426b12c --- /dev/null +++ b/test/integration/setAuthor/test.json @@ -0,0 +1,4 @@ +{ + "description": "In this test the author of a commit is set to a different name/email.", + "speed": 5 +}