mirror of
https://github.com/gogs/gogs.git
synced 2025-12-22 08:09:59 +01:00
pull_request: able to ignore whitespace when check conflict (#4834)
This commit is contained in:
@@ -739,6 +739,7 @@ settings.tracker_issue_style.numeric = Numeric
|
|||||||
settings.tracker_issue_style.alphanumeric = Alphanumeric
|
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.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_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.pulls.allow_rebase_merge = Allow use rebase to merge commits
|
||||||
settings.danger_zone = Danger Zone
|
settings.danger_zone = Danger Zone
|
||||||
settings.cannot_fork_to_same_owner = You cannot fork a repository to its original owner.
|
settings.cannot_fork_to_same_owner = You cannot fork a repository to its original owner.
|
||||||
|
|||||||
@@ -392,10 +392,16 @@ func (pr *PullRequest) testPatch() (err error) {
|
|||||||
return fmt.Errorf("UpdateLocalCopy [%d]: %v", pr.BaseRepoID, err)
|
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
|
pr.Status = PULL_REQUEST_STATUS_CHECKING
|
||||||
_, stderr, err := process.ExecDir(-1, pr.BaseRepo.LocalCopyPath(),
|
_, stderr, err := process.ExecDir(-1, pr.BaseRepo.LocalCopyPath(),
|
||||||
fmt.Sprintf("testPatch (git apply --check): %d", pr.BaseRepo.ID),
|
fmt.Sprintf("testPatch (git apply --check): %d", pr.BaseRepo.ID),
|
||||||
"git", "apply", "--check", patchPath)
|
"git", args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Trace("PullRequest[%d].testPatch (apply): has conflit\n%s", pr.ID, stderr)
|
log.Trace("PullRequest[%d].testPatch (apply): has conflit\n%s", pr.ID, stderr)
|
||||||
pr.Status = PULL_REQUEST_STATUS_CONFLICT
|
pr.Status = PULL_REQUEST_STATUS_CONFLICT
|
||||||
|
|||||||
@@ -184,6 +184,7 @@ type Repository struct {
|
|||||||
ExternalTrackerStyle string
|
ExternalTrackerStyle string
|
||||||
ExternalMetas map[string]string `xorm:"-"`
|
ExternalMetas map[string]string `xorm:"-"`
|
||||||
EnablePulls bool `xorm:"NOT NULL DEFAULT true"`
|
EnablePulls bool `xorm:"NOT NULL DEFAULT true"`
|
||||||
|
PullsIgnoreWhitespace bool `xorm:"NOT NULL DEFAULT false"`
|
||||||
PullsAllowRebase bool `xorm:"NOT NULL DEFAULT false"`
|
PullsAllowRebase bool `xorm:"NOT NULL DEFAULT false"`
|
||||||
|
|
||||||
IsFork bool `xorm:"NOT NULL DEFAULT false"`
|
IsFork bool `xorm:"NOT NULL DEFAULT false"`
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -102,6 +102,7 @@ type RepoSetting struct {
|
|||||||
TrackerURLFormat string
|
TrackerURLFormat string
|
||||||
TrackerIssueStyle string
|
TrackerIssueStyle string
|
||||||
EnablePulls bool
|
EnablePulls bool
|
||||||
|
PullsIgnoreWhitespace bool
|
||||||
PullsAllowRebase bool
|
PullsAllowRebase bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -147,6 +147,7 @@ func SettingsPost(c *context.Context, f form.RepoSetting) {
|
|||||||
repo.ExternalTrackerFormat = f.TrackerURLFormat
|
repo.ExternalTrackerFormat = f.TrackerURLFormat
|
||||||
repo.ExternalTrackerStyle = f.TrackerIssueStyle
|
repo.ExternalTrackerStyle = f.TrackerIssueStyle
|
||||||
repo.EnablePulls = f.EnablePulls
|
repo.EnablePulls = f.EnablePulls
|
||||||
|
repo.PullsIgnoreWhitespace = f.PullsIgnoreWhitespace
|
||||||
repo.PullsAllowRebase = f.PullsAllowRebase
|
repo.PullsAllowRebase = f.PullsAllowRebase
|
||||||
|
|
||||||
if err := models.UpdateRepository(repo, false); err != nil {
|
if err := models.UpdateRepository(repo, false); err != nil {
|
||||||
|
|||||||
@@ -197,12 +197,20 @@
|
|||||||
<label>{{.i18n.Tr "repo.settings.pulls_desc"}}</label>
|
<label>{{.i18n.Tr "repo.settings.pulls_desc"}}</label>
|
||||||
</div>
|
</div>
|
||||||
</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">
|
<div class="ui checkbox">
|
||||||
<input name="pulls_allow_rebase" type="checkbox" {{if .Repository.PullsAllowRebase}}checked{{end}}>
|
<input name="pulls_allow_rebase" type="checkbox" {{if .Repository.PullsAllowRebase}}checked{{end}}>
|
||||||
<label>{{.i18n.Tr "repo.settings.pulls.allow_rebase_merge"}}</label>
|
<label>{{.i18n.Tr "repo.settings.pulls.allow_rebase_merge"}}</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
<div class="field">
|
<div class="field">
|
||||||
|
|||||||
Reference in New Issue
Block a user