Merge pull request #140 from sgotti/gitsource_pr_dont_set_branch

gitsources: don't set branch value when in a pull request
This commit is contained in:
Simone Gotti 2019-10-15 09:15:05 +02:00 committed by GitHub
commit 2d813461d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 15 deletions

View File

@ -162,7 +162,6 @@ func webhookDataFromPullRequest(hook *pullRequestHook) *types.WebhookData {
SSHURL: hook.Repo.SSHURL,
Ref: fmt.Sprintf("refs/pull/%d/head", hook.Number),
CommitLink: fmt.Sprintf("%s/commit/%s", hook.Repo.URL, hook.PullRequest.Head.Sha),
Branch: hook.PullRequest.Base.Ref,
Message: hook.PullRequest.Title,
Sender: sender,
PullRequestID: strconv.FormatInt(hook.PullRequest.ID, 10),

View File

@ -123,7 +123,6 @@ func webhookDataFromPullRequest(hook *github.PullRequestEvent) (*types.WebhookDa
SSHURL: *hook.Repo.SSHURL,
Ref: fmt.Sprintf("refs/pull/%d/head", *hook.Number),
CommitLink: fmt.Sprintf("%s/commit/%s", *hook.Repo.HTMLURL, *hook.PullRequest.Head.SHA),
Branch: *hook.PullRequest.Base.Ref,
Message: *hook.PullRequest.Title,
Sender: *sender,
PullRequestID: strconv.Itoa(*hook.PullRequest.Number),

View File

@ -104,9 +104,7 @@ func webhookDataFromPush(hook *pushHook) (*types.WebhookData, error) {
SSHURL: hook.Project.SSHURL,
Ref: hook.Ref,
CommitLink: hook.Commits[0].URL,
//CompareLink: hook.Compare,
//CommitLink: fmt.Sprintf("%s/commit/%s", hook.Repo.URL, hook.After),
Sender: sender,
Sender: sender,
Repo: types.WebhookDataRepo{
Path: hook.Project.PathWithNamespace,
@ -142,18 +140,12 @@ func webhookDataFromPullRequest(hook *pullRequestHook) *types.WebhookData {
if sender == "" {
sender = hook.User.Username
}
//sender := hook.ObjectAttributes.LastCommit.Author.Name
//if sender == "" {
// sender := hook.ObjectAttributes.LastCommit.Author.UserName
//}
build := &types.WebhookData{
Event: types.WebhookEventPullRequest,
CommitSHA: hook.ObjectAttributes.LastCommit.ID,
SSHURL: hook.Project.SSHURL,
Ref: fmt.Sprintf("refs/merge-requests/%d/head", hook.ObjectAttributes.Iid),
//CommitLink: fmt.Sprintf("%s/commit/%s", hook.Repo.URL, hook.PullRequest.Head.Sha),
Event: types.WebhookEventPullRequest,
CommitSHA: hook.ObjectAttributes.LastCommit.ID,
SSHURL: hook.Project.SSHURL,
Ref: fmt.Sprintf("refs/merge-requests/%d/head", hook.ObjectAttributes.Iid),
CommitLink: hook.ObjectAttributes.LastCommit.URL,
Branch: hook.ObjectAttributes.SourceBranch,
Message: hook.ObjectAttributes.Title,
Sender: sender,
PullRequestID: strconv.Itoa(hook.ObjectAttributes.Iid),