-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Pull Request merge options - Ignore white-space for conflict chec…
…king, Rebase, Squash merge (#3188) * Pull request options migration and UI in settings * Add ignore whitespace functionality * Fix settings if pull requests are disabled * Fix migration transaction * Merge with Rebase functionality * UI changes and related functionality for pull request merging button * Implement squash functionality * Fix rebase merging * Fix pull request merge tests * Add squash and rebase tests * Fix API method to reuse default message functions * Some refactoring and small fixes * Remove more hardcoded values from tests * Remove unneeded check from API method * Fix variable name and comment typo * Fix reset commit count after PR merge
- Loading branch information
Showing
20 changed files
with
529 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright 2017 The Gitea Authors. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package migrations | ||
|
||
import ( | ||
"fmt" | ||
|
||
"code.gitea.io/gitea/modules/util" | ||
|
||
"github.com/go-xorm/xorm" | ||
) | ||
|
||
func addPullRequestOptions(x *xorm.Engine) error { | ||
// RepoUnit describes all units of a repository | ||
type RepoUnit struct { | ||
ID int64 | ||
RepoID int64 `xorm:"INDEX(s)"` | ||
Type int `xorm:"INDEX(s)"` | ||
Config map[string]interface{} `xorm:"JSON"` | ||
CreatedUnix util.TimeStamp `xorm:"INDEX CREATED"` | ||
} | ||
|
||
sess := x.NewSession() | ||
defer sess.Close() | ||
if err := sess.Begin(); err != nil { | ||
return err | ||
} | ||
|
||
//Updating existing issue units | ||
units := make([]*RepoUnit, 0, 100) | ||
if err := sess.Where("`type` = ?", V16UnitTypePRs).Find(&units); err != nil { | ||
return fmt.Errorf("Query repo units: %v", err) | ||
} | ||
for _, unit := range units { | ||
if unit.Config == nil { | ||
unit.Config = make(map[string]interface{}) | ||
} | ||
if _, ok := unit.Config["IgnoreWhitespaceConflicts"]; !ok { | ||
unit.Config["IgnoreWhitespaceConflicts"] = false | ||
} | ||
if _, ok := unit.Config["AllowMerge"]; !ok { | ||
unit.Config["AllowMerge"] = true | ||
} | ||
if _, ok := unit.Config["AllowRebase"]; !ok { | ||
unit.Config["AllowRebase"] = true | ||
} | ||
if _, ok := unit.Config["AllowSquash"]; !ok { | ||
unit.Config["AllowSquash"] = true | ||
} | ||
if _, err := sess.ID(unit.ID).Cols("config").Update(unit); err != nil { | ||
return err | ||
} | ||
} | ||
return sess.Commit() | ||
} |
Oops, something went wrong.