Skip to content

Commit

Permalink
Merge pull request #85 from shubhag/before_after_attrs
Browse files Browse the repository at this point in the history
Set before & after attribute for gitlab & bitbucket push event
  • Loading branch information
bradrydzewski committed Nov 30, 2020
2 parents c0438b4 + 0d5c39a commit ff8ad5b
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions scm/driver/bitbucket/testdata/webhooks/push.json.golden
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"Ref": "refs/heads/master",
"Before": "40e7580cf11311d84a6e5e97e2cbba6df1675750",
"After": "141977fedf5cf35aa290ac87d4b5177ac4cd9de1",
"Repo": {
"ID": "{bc771cbf-829e-4c4b-b71f-a0eb3ac2b860}",
"Namespace": "brydzewski",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"Ref": "refs/heads/develop",
"After": "141977fedf5cf35aa290ac87d4b5177ac4cd9de1",
"Repo": {
"ID": "{bc771cbf-829e-4c4b-b71f-a0eb3ac2b860}",
"Namespace": "brydzewski",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"Ref": "refs/tags/feature/x",
"After": "141977fedf5cf35aa290ac87d4b5177ac4cd9de1",
"Repo": {
"ID": "{bc771cbf-829e-4c4b-b71f-a0eb3ac2b860}",
"Namespace": "brydzewski",
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 @@ -416,6 +416,7 @@ func convertPushHook(src *pushHook) *scm.PushHook {
dst := &scm.PushHook{
Ref: scm.ExpandRef(change.New.Name, "refs/heads/"),
Before: change.Old.Target.Hash,
After: change.New.Target.Hash,
Commit: scm.Commit{
Sha: change.New.Target.Hash,
Message: change.New.Target.Message,
Expand Down
2 changes: 2 additions & 0 deletions scm/driver/gitlab/testdata/webhooks/branch_create.json.golden
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"Ref": "refs/heads/feature",
"Before": "0000000000000000000000000000000000000000",
"After": "c4c79227ed610f1151f05bbc5be33b4f340d39c8",
"Repo": {
"ID": "4861503",
"Namespace": "gitlab-org",
Expand Down
2 changes: 2 additions & 0 deletions scm/driver/gitlab/testdata/webhooks/push.json.golden
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"Ref": "refs/heads/master",
"Before": "9217710ce8c7e1eae7a5d1c45f6e43e1c769f866",
"After": "2adc9465c4edfc33834e173fe89436a7cb899a1d",
"Repo": {
"ID": "4861503",
"Namespace": "gitlab-org",
Expand Down
2 changes: 2 additions & 0 deletions scm/driver/gitlab/testdata/webhooks/tag_create.json.golden
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"Ref": "refs/tags/v1.0.0",
"Before": "0000000000000000000000000000000000000000",
"After": "2adc9465c4edfc33834e173fe89436a7cb899a1d",
"Repo": {
"ID": "4861503",
"Namespace": "gitlab-org",
Expand Down
4 changes: 3 additions & 1 deletion scm/driver/gitlab/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ func convertPushHook(src *pushHook) *scm.PushHook {
}
namespace, name := scm.Split(src.Project.PathWithNamespace)
dst := &scm.PushHook{
Ref: scm.ExpandRef(src.Ref, "refs/heads/"),
Ref: scm.ExpandRef(src.Ref, "refs/heads/"),
Before: src.Before,
After: src.After,
Repo: scm.Repository{
ID: strconv.Itoa(src.Project.ID),
Namespace: namespace,
Expand Down

0 comments on commit ff8ad5b

Please sign in to comment.