From fc445bddcbf15cc3d4b99fac119311b057b6e7b1 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Mon, 9 Dec 2019 03:16:22 +0100 Subject: [PATCH 1/3] simple fix --- modules/repofiles/file.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/repofiles/file.go b/modules/repofiles/file.go index 801f770e02ffa..bf7a7ac11e0ed 100644 --- a/modules/repofiles/file.go +++ b/modules/repofiles/file.go @@ -121,5 +121,5 @@ func GetAuthorAndCommitterUsers(author, committer *IdentityOptions, doer *models if committerUser == nil { committerUser = authorUser // No valid committer so use the author as the committer (was set to a valid user above) } - return authorUser, committerUser + return committerUser, authorUser } From 17052b2dc6e7494286c6285e9a9473562dc9e53a Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Mon, 9 Dec 2019 04:01:53 +0100 Subject: [PATCH 2/3] fix test too --- integrations/api_repo_file_create_test.go | 12 ++++++------ integrations/api_repo_file_update_test.go | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/integrations/api_repo_file_create_test.go b/integrations/api_repo_file_create_test.go index eb437edf03f9a..53042b5d0a532 100644 --- a/integrations/api_repo_file_create_test.go +++ b/integrations/api_repo_file_create_test.go @@ -30,12 +30,12 @@ func getCreateFileOptions() api.CreateFileOptions { NewBranchName: "master", Message: "Making this new file new/file.txt", Author: api.Identity{ - Name: "John Doe", - Email: "johndoe@example.com", + Name: "Anne Doe", + Email: "annedoe@example.com", }, Committer: api.Identity{ - Name: "Jane Doe", - Email: "janedoe@example.com", + Name: "John Doe", + Email: "johndoe@example.com", }, }, Content: contentEncoded, @@ -77,8 +77,8 @@ func getExpectedFileResponseForCreate(commitID, treePath string) *api.FileRespon HTMLURL: setting.AppURL + "user2/repo1/commit/" + commitID, Author: &api.CommitUser{ Identity: api.Identity{ - Name: "Jane Doe", - Email: "janedoe@example.com", + Name: "Anne Doe", + Email: "annedoe@example.com", }, }, Committer: &api.CommitUser{ diff --git a/integrations/api_repo_file_update_test.go b/integrations/api_repo_file_update_test.go index 236cb8eb30884..369e48d6461d6 100644 --- a/integrations/api_repo_file_update_test.go +++ b/integrations/api_repo_file_update_test.go @@ -35,8 +35,8 @@ func getUpdateFileOptions() *api.UpdateFileOptions { Email: "johndoe@example.com", }, Committer: api.Identity{ - Name: "Jane Doe", - Email: "janedoe@example.com", + Name: "Anne Doe", + Email: "annedoe@example.com", }, }, SHA: "103ff9234cefeee5ec5361d22b49fbb04d385885", @@ -80,14 +80,14 @@ func getExpectedFileResponseForUpdate(commitID, treePath string) *api.FileRespon HTMLURL: setting.AppURL + "user2/repo1/commit/" + commitID, Author: &api.CommitUser{ Identity: api.Identity{ - Name: "Jane Doe", - Email: "janedoe@example.com", + Name: "John Doe", + Email: "johndoe@example.com", }, }, Committer: &api.CommitUser{ Identity: api.Identity{ - Name: "John Doe", - Email: "johndoe@example.com", + Name: "Anne Doe", + Email: "annedoe@example.com", }, }, Message: "My update of README.md\n", From 1fb6e40280c9af3f23e37a4084a111c757786c3f Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Mon, 9 Dec 2019 04:17:27 +0100 Subject: [PATCH 3/3] repair more twists use same sequence: first Author, then Commiter --- modules/repofiles/delete.go | 2 +- modules/repofiles/file.go | 4 ++-- modules/repofiles/update.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/repofiles/delete.go b/modules/repofiles/delete.go index 2210faae6bb60..95b0804025a1d 100644 --- a/modules/repofiles/delete.go +++ b/modules/repofiles/delete.go @@ -69,7 +69,7 @@ func DeleteRepoFile(repo *models.Repository, doer *models.User, opts *DeleteRepo message := strings.TrimSpace(opts.Message) - author, committer := GetAuthorAndCommitterUsers(opts.Committer, opts.Author, doer) + author, committer := GetAuthorAndCommitterUsers(opts.Author, opts.Committer, doer) t, err := NewTemporaryUploadRepository(repo) if err != nil { diff --git a/modules/repofiles/file.go b/modules/repofiles/file.go index bf7a7ac11e0ed..abd14b1db817f 100644 --- a/modules/repofiles/file.go +++ b/modules/repofiles/file.go @@ -80,7 +80,7 @@ func GetFileCommitResponse(repo *models.Repository, commit *git.Commit) (*api.Fi } // GetAuthorAndCommitterUsers Gets the author and committer user objects from the IdentityOptions -func GetAuthorAndCommitterUsers(author, committer *IdentityOptions, doer *models.User) (committerUser, authorUser *models.User) { +func GetAuthorAndCommitterUsers(author, committer *IdentityOptions, doer *models.User) (authorUser, committerUser *models.User) { // Committer and author are optional. If they are not the doer (not same email address) // then we use bogus User objects for them to store their FullName and Email. // If only one of the two are provided, we set both of them to it. @@ -121,5 +121,5 @@ func GetAuthorAndCommitterUsers(author, committer *IdentityOptions, doer *models if committerUser == nil { committerUser = authorUser // No valid committer so use the author as the committer (was set to a valid user above) } - return committerUser, authorUser + return authorUser, committerUser } diff --git a/modules/repofiles/update.go b/modules/repofiles/update.go index 0042be52cde8a..4d2f1d5f045d8 100644 --- a/modules/repofiles/update.go +++ b/modules/repofiles/update.go @@ -168,7 +168,7 @@ func CreateOrUpdateRepoFile(repo *models.Repository, doer *models.User, opts *Up message := strings.TrimSpace(opts.Message) - author, committer := GetAuthorAndCommitterUsers(opts.Committer, opts.Author, doer) + author, committer := GetAuthorAndCommitterUsers(opts.Author, opts.Committer, doer) t, err := NewTemporaryUploadRepository(repo) if err != nil {