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

Bitbucket sha fix for merged pr #225

Merged
merged 4 commits into from
Sep 14, 2022
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
5 changes: 5 additions & 0 deletions scm/driver/bitbucket/pr.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ type pr struct {
HTML string `json:"html"`
Type string `json:"type"`
} `json:"summary"`
MergeCommit struct {
Type string `json:"type"`
Hash string `json:"hash"`
} `json:"merge_commit"`
Source reference `json:"source"`
State string `json:"state"`
Author user `json:"author"`
Expand Down Expand Up @@ -149,6 +153,7 @@ func convertPullRequest(from *pr) *scm.PullRequest {
Title: from.Title,
Body: from.Description,
Sha: from.Source.Commit.Hash,
Merge: from.MergeCommit.Hash,
Source: from.Source.Branch.Name,
Target: from.Destination.Branch.Name,
Fork: from.Source.Repository.FullName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"Title": "Awesome new feature",
"Body": "made some changes",
"Sha": "0704fc5beccc",
"Merge": "4f8f6de9d0ff",
"Ref": "refs/pull-requests/1/from",
"Source": "develop",
"Target": "master",
Expand Down
1 change: 1 addition & 0 deletions scm/driver/bitbucket/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,7 @@ func convertPullRequestHook(src *webhook) *scm.PullRequestHook {
Title: src.PullRequest.Title,
Body: src.PullRequest.Description,
Sha: src.PullRequest.Source.Commit.Hash,
Merge: src.PullRequest.MergeCommit.Hash,
Ref: fmt.Sprintf("refs/pull-requests/%d/from", src.PullRequest.ID),
Source: src.PullRequest.Source.Branch.Name,
Target: src.PullRequest.Destination.Branch.Name,
Expand Down
7 changes: 7 additions & 0 deletions scm/driver/stash/pr.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ type pr struct {
Links struct {
Self []link `json:"self"`
} `json:"links"`
Properties struct {
MergeCommit struct {
ID string `json:"id"`
DisplayID string `json:"displayId"`
} `json:"mergeCommit"`
} `json:"properties"`
}

type prs struct {
Expand Down Expand Up @@ -221,6 +227,7 @@ func convertPullRequest(from *pr) *scm.PullRequest {
Title: from.Title,
Body: from.Description,
Sha: from.FromRef.LatestCommit,
Merge: from.Properties.MergeCommit.ID,
Ref: fmt.Sprintf("refs/pull-requests/%d/from", from.ID),
Source: from.FromRef.DisplayID,
Target: from.ToRef.DisplayID,
Expand Down
1 change: 1 addition & 0 deletions scm/driver/stash/testdata/webhooks/pr_merged.json.golden
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"Title": "Develop",
"Body": "* added LICENSE\r\n* add COPYING file",
"Sha": "b9eaed50a03c073b20dfa82e5e753d295e7f0e56",
"Merge": "83f836ca538dc4f43d29fda46a5b85ea49f1b8e7",
"Ref": "refs/pull-requests/3/from",
"Source": "develop",
"Target": "master",
Expand Down