Skip to content
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

feat: add label in case of conflict #652

Merged
merged 2 commits into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions internal/pkg/externalplugins/cherrypicker/cherrypicker.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,9 +561,11 @@ func (s *Server) handle(logger *logrus.Entry, requestor string,

// Title for GitHub issue/PR.
title = fmt.Sprintf("%s (#%d)", title, num)
hasConflicts := false

// Try git am --3way localPath.
if err := r.Am(localPath); err != nil {
hasConflicts = true
var errs []error
logger.WithError(err).Warnf("Failed to apply #%d on top of target branch %q.", num, targetBranch)
if opts.IssueOnConflict {
Expand Down Expand Up @@ -678,6 +680,11 @@ func (s *Server) handle(logger *logrus.Entry, requestor string,
labels.Insert(pickedLabel)
}

// Add conflicts label.
if hasConflicts {
Rustin170506 marked this conversation as resolved.
Show resolved Hide resolved
labels.Insert(tiexternalplugins.CherryPickHasConflicts)
}

if err := s.GitHubClient.AddLabels(org, repo, createdNum, labels.List()...); err != nil {
logger.WithError(err).Warnf("Failed to add labels %v", labels.List())
}
Expand Down
2 changes: 2 additions & 0 deletions internal/pkg/externalplugins/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import "fmt"
const (
// CanMergeLabel is the name of the merge label applied by the merge plugin.
CanMergeLabel = "status/can-merge"
// CherryPickHasConflicts is the name of the conflicts label applied by the cherry-pick plugin.
CherryPickHasConflicts = "status/cherry-pick-has-conflicts"
)

const (
Expand Down