-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Pull Request merge options - Ignore white-space for conflict checking, Rebase, Squash merge #3188
Add Pull Request merge options - Ignore white-space for conflict checking, Rebase, Squash merge #3188
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3188 +/- ##
==========================================
+ Coverage 34.62% 34.86% +0.24%
==========================================
Files 277 278 +1
Lines 40298 40506 +208
==========================================
+ Hits 13952 14122 +170
- Misses 24298 24299 +1
- Partials 2048 2085 +37
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And maybe splited two PRs for quick review.
models/migrations/v54.go
Outdated
sess := x.NewSession() | ||
defer sess.Close() | ||
|
||
//Updating existing issue units |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need sess.Begin()
@lunny how do you mean to split them? |
@lunny fixed |
Fair and early notice: please add tests (at some point, I understand it's a WIP right now) |
@lafriks When I do a squash, the author of the squashed commit is Perhaps we should include authorship check in our tests? |
@ethantkoenig when squashing author is set as PR poster (as theoretically there could be multiple commit authors) |
@lafriks |
Tried again, same thing happened. Let me know if you aren't able to reproduce |
@ethantkoenig it is same as currently with merge commit. It uses
So you have probably set for user to keep email address private. |
You're right, good catch |
I'm out of ideas how to preserve commit info in PR when merged with squash or rebase :( As there is no merge commit to reference. Especially for squash merge as original commits are lost completely when PR head branch is deleted. |
Looks like github does that by keeping commit info in |
I think it is ready for review now, please test it and comment :) |
Automatically adding all commit messages to extended commit message for squash should be implemented as other PR to not make this PR even bigger |
aab0620
to
f53d612
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good, mostly nits
integrations/pull_merge_test.go
Outdated
@@ -16,16 +16,17 @@ import ( | |||
"github.com/stretchr/testify/assert" | |||
) | |||
|
|||
func testPullMerge(t *testing.T, session *TestSession, user, repo, pullnum string) *httptest.ResponseRecorder { | |||
func testPullMerge(t *testing.T, session *TestSession, user, repo, pullnum, mergeStyle string) *httptest.ResponseRecorder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: use models.MergeStyle
models/pull.go
Outdated
|
||
// GetDefaultSquashMessage returns default message used when squash and merging pull request | ||
func (pr *PullRequest) GetDefaultSquashMessage() string { | ||
if pr.Issue == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: This check is unnecessary, pr.LoadIssue()
already does it
models/pull.go
Outdated
|
||
const ( | ||
// MergeStyleRegular create merge commit | ||
MergeStyleRegular MergeStyle = "merge" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe MergeStyleMerge
would be better?
options/locale/locale_en-US.ini
Outdated
@@ -755,7 +755,12 @@ pulls.is_checking = "The conflict checking is still in progress; please refresh | |||
pulls.can_auto_merge_desc = This pull request can be merged automatically. | |||
pulls.cannot_auto_merge_desc = This pull request cannot be merged automatically because there are conflicts. | |||
pulls.cannot_auto_merge_helper = Please merge manually in order to resolve the conflicts. | |||
pulls.no_merge_desc = This pull request can not be merged as no merge options enabled. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pull request can not be merged as no merge options are enabled.
routers/api/v1/repo/pull.go
Outdated
form.Do = "merge" | ||
} | ||
|
||
if models.MergeStyle(form.Do) != models.MergeStyleRegular && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: This is check unnecessary, since pr.Merge
already checks the provided mergeStyle
.
models/pull.go
Outdated
if err = pr.GetHeadRepo(); err != nil { | ||
return fmt.Errorf("GetHeadRepo: %v", err) | ||
} else if err = pr.GetBaseRepo(); err != nil { | ||
return fmt.Errorf("GetBaseRepo: %v", err) | ||
} | ||
|
||
pullsConfig := pr.BaseRepo.MustGetUnit(UnitTypePullRequests).PullRequestsConfig() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use .GetUnit(..)
, so we don't unnecessarily ignore an error.
options/locale/locale_en-US.ini
Outdated
pulls.merge_pull_request = Merge Pull Request | ||
pulls.rebase_merge_pull_request = Rebase and Merge | ||
pulls.squash_merge_pull_request = Squash and Merge | ||
pulls.invalid_merge_option = You can not use this merge option for this Pull Request |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Pull Request -> pull request
options/locale/locale_en-US.ini
Outdated
@@ -894,6 +899,10 @@ settings.tracker_url_format_desc = You can use placeholder <code>{user} {repo} { | |||
settings.enable_timetracker = Enable time tracker | |||
settings.allow_only_contributors_to_track_time = Allow only contributors to track time | |||
settings.pulls_desc = Enable pull requests to accept public contributions | |||
settings.pulls.ignore_whitespace = Ignore changes in whitespaces when checking conflicts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: whitespaces -> whitespace
models/pull.go
Outdated
@@ -109,6 +109,22 @@ func (pr *PullRequest) loadIssue(e Engine) (err error) { | |||
return err | |||
} | |||
|
|||
// GetDefaultMergeMessage returns default message used when merging pull request | |||
func (pr *PullRequest) GetDefaultMergeMessage() string { | |||
return fmt.Sprintf("Merge branch '%s' of %s/%s into %s", pr.HeadBranch, pr.HeadUserName, pr.HeadRepo.Name, pr.BaseBranch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pr.HeadRepo
may not always loaded, I think that is why CI is failing.
integrations/pull_merge_test.go
Outdated
@@ -58,7 +59,34 @@ func TestPullMerge(t *testing.T) { | |||
|
|||
elem := strings.Split(test.RedirectURL(resp), "/") | |||
assert.EqualValues(t, "pulls", elem[3]) | |||
testPullMerge(t, session, elem[1], elem[2], elem[4]) | |||
testPullMerge(t, session, elem[1], elem[2], elem[4], "merge") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's not too hard, could we check that the merge itself was successful, (that a commit was created, that correct merge style was used, etc.)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lafriks Is this doable?
fmt.Sprintf("PullRequest.Merge (git merge --no-ff --no-commit): %s", tmpBasePath), | ||
"git", "merge", "--no-ff", "--no-commit", "head_repo/"+pr.HeadBranch); err != nil { | ||
return fmt.Errorf("git merge --no-ff --no-commit [%s]: %v - %s", tmpBasePath, err, stderr) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is not the right place, but shouldn't this functionality be moved to the "git" module ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably that would be better place but as it was there already that should be done in other PR
03bfe37
to
60b2092
Compare
@ethantkoenig can I merge? as now approvals also count as LG-TM :) |
@ethantkoenig oh, ok will add that next year :)) |
@lafriks is there one still waiting a change? |
@lunny yes @ethantkoenig wants more tests |
@lafriks @ethantkoenig I think we can merge this and @lafriks could take another PR to add tests. |
okay |
@lunny @ethantkoenig ok, I will improve tests in other PR |
Fixes #712
Add Pull Request merge options:
Tasks:
Fix wrong display of merged PR commits and changes- should be implemented as separate PR (issue Keep merged PR info in hidden branch #3222)Screenshots: