Browse Source

pull_request: able to ignore whitespace when check conflict (#4834)

pull/4722/merge
Unknwon 7 years ago
parent
commit
3b8b8a2ee3
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
  1. 1
      conf/locale/locale_en-US.ini
  2. 8
      models/pull.go
  3. 1
      models/repo.go
  4. 4
      pkg/bindata/bindata.go
  5. 1
      pkg/form/repo.go
  6. 1
      routes/repo/setting.go
  7. 10
      templates/repo/settings/options.tmpl

1
conf/locale/locale_en-US.ini

@ -739,6 +739,7 @@ settings.tracker_issue_style.numeric = Numeric
settings.tracker_issue_style.alphanumeric = Alphanumeric
settings.tracker_url_format_desc = You can use placeholder <code>{user} {repo} {index}</code> for user name, repository name and issue index.
settings.pulls_desc = Enable pull requests to accept public contributions
settings.pulls.ignore_whitespace = Ignore changes in whitespace
settings.pulls.allow_rebase_merge = Allow use rebase to merge commits
settings.danger_zone = Danger Zone
settings.cannot_fork_to_same_owner = You cannot fork a repository to its original owner.

8
models/pull.go

@ -392,10 +392,16 @@ func (pr *PullRequest) testPatch() (err error) {
return fmt.Errorf("UpdateLocalCopy [%d]: %v", pr.BaseRepoID, err)
}
args := []string{"apply", "--check"}
if pr.BaseRepo.PullsIgnoreWhitespace {
args = append(args, "--ignore-whitespace")
}
args = append(args, patchPath)
pr.Status = PULL_REQUEST_STATUS_CHECKING
_, stderr, err := process.ExecDir(-1, pr.BaseRepo.LocalCopyPath(),
fmt.Sprintf("testPatch (git apply --check): %d", pr.BaseRepo.ID),
"git", "apply", "--check", patchPath)
"git", args...)
if err != nil {
log.Trace("PullRequest[%d].testPatch (apply): has conflit\n%s", pr.ID, stderr)
pr.Status = PULL_REQUEST_STATUS_CONFLICT

1
models/repo.go

@ -184,6 +184,7 @@ type Repository struct {
ExternalTrackerStyle string
ExternalMetas map[string]string `xorm:"-"`
EnablePulls bool `xorm:"NOT NULL DEFAULT true"`
PullsIgnoreWhitespace bool `xorm:"NOT NULL DEFAULT false"`
PullsAllowRebase bool `xorm:"NOT NULL DEFAULT false"`
IsFork bool `xorm:"NOT NULL DEFAULT false"`

4
pkg/bindata/bindata.go

File diff suppressed because one or more lines are too long

1
pkg/form/repo.go

@ -102,6 +102,7 @@ type RepoSetting struct {
TrackerURLFormat string
TrackerIssueStyle string
EnablePulls bool
PullsIgnoreWhitespace bool
PullsAllowRebase bool
}

1
routes/repo/setting.go

@ -147,6 +147,7 @@ func SettingsPost(c *context.Context, f form.RepoSetting) {
repo.ExternalTrackerFormat = f.TrackerURLFormat
repo.ExternalTrackerStyle = f.TrackerIssueStyle
repo.EnablePulls = f.EnablePulls
repo.PullsIgnoreWhitespace = f.PullsIgnoreWhitespace
repo.PullsAllowRebase = f.PullsAllowRebase
if err := models.UpdateRepository(repo, false); err != nil {

10
templates/repo/settings/options.tmpl

@ -197,12 +197,20 @@
<label>{{.i18n.Tr "repo.settings.pulls_desc"}}</label>
</div>
</div>
<div class="ui segment field {{if not .Repository.EnablePulls}}disabled{{end}}" id="pull_box">
<div class="ui segment {{if not .Repository.EnablePulls}}disabled{{end}}" id="pull_box">
<div class="field">
<div class="ui checkbox">
<input name="pulls_ignore_whitespace" type="checkbox" {{if .Repository.PullsIgnoreWhitespace}}checked{{end}}>
<label>{{.i18n.Tr "repo.settings.pulls.ignore_whitespace"}}</label>
</div>
</div>
<div class="field">
<div class="ui checkbox">
<input name="pulls_allow_rebase" type="checkbox" {{if .Repository.PullsAllowRebase}}checked{{end}}>
<label>{{.i18n.Tr "repo.settings.pulls.allow_rebase_merge"}}</label>
</div>
</div>
</div>
{{end}}
<div class="field">

Loading…
Cancel
Save