Skip to content

Commit

Permalink
chore: Add Patch field to scm.Change
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Bayer <[email protected]>
  • Loading branch information
abayer committed Aug 11, 2020
1 parent c8ca98d commit d835687
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions scm/driver/github/pr.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ func convertChange(from *file) *scm.Change {
Added: from.Status == "added",
Deleted: from.Status == "deleted",
Renamed: from.Status == "moved",
Patch: from.Patch,
Additions: from.Additions,
Deletions: from.Deletions,
Changes: from.Changes,
Expand Down
5 changes: 3 additions & 2 deletions scm/driver/github/testdata/changes.json.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"Link": "https://api.github.com/repos/octocat/Hello-World/git/trees/b4eecafa9be2f2006ce1b709d6857b07069b4608"
},
"BlobURL": "https://github.com/octocat/Hello-World/blob/6dcb09b5b57875f334f61aebed695e2e4193db5e/file1.txt",
"Sha": "bbcd538c8e72b8c175046e27cc8f907076331401"
"Sha": "bbcd538c8e72b8c175046e27cc8f907076331401",
"Patch": "@@ -132,7 +132,7 @@ module Test @@ -1000,7 +1000,7 @@ module Test"
}
]
]
5 changes: 3 additions & 2 deletions scm/driver/github/testdata/pr_files.json.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"Link": "https://api.github.com/repos/octocat/Hello-World/git/trees/b4eecafa9be2f2006ce1b709d6857b07069b4608"
},
"BlobURL": "https://github.com/octocat/Hello-World/blob/6dcb09b5b57875f334f61aebed695e2e4193db5e/file1.txt",
"Sha": "bbcd538c8e72b8c175046e27cc8f907076331401"
"Sha": "bbcd538c8e72b8c175046e27cc8f907076331401",
"Patch": "@@ -132,7 +132,7 @@ module Test @@ -1000,7 +1000,7 @@ module Test"
}
]
]
2 changes: 2 additions & 0 deletions scm/driver/gitlab/pr.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ type change struct {
Added bool `json:"new_file"`
Renamed bool `json:"renamed_file"`
Deleted bool `json:"deleted_file"`
Diff string `json:"diff"`
}

type prInput struct {
Expand Down Expand Up @@ -403,6 +404,7 @@ func convertChange(from *change) *scm.Change {
Added: from.Added,
Deleted: from.Deleted,
Renamed: from.Renamed,
Patch: from.Diff,
}
if to.Path == "" {
to.Path = from.OldPath
Expand Down
3 changes: 2 additions & 1 deletion scm/driver/gitlab/testdata/commit_diff.json.golden
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"PreviousPath": "doc/update/5.4-to-6.0.md",
"Added": true,
"Renamed": false,
"Deleted": false
"Deleted": false,
"Patch": "--- a/doc/update/5.4-to-6.0.md\n+++ b/doc/update/5.4-to-6.0.md\n@@ -71,6 +71,8 @@\n sudo -u git -H bundle exec rake migrate_keys RAILS_ENV=production\n sudo -u git -H bundle exec rake migrate_inline_notes RAILS_ENV=production\n \n+sudo -u git -H bundle exec rake gitlab:assets:compile RAILS_ENV=production\n+\n ```\n \n ### 6. Update config files"
}
]
3 changes: 2 additions & 1 deletion scm/driver/gitlab/testdata/merge_diff.json.golden
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"PreviousPath": "VERSION",
"Added": false,
"Renamed": false,
"Deleted": false
"Deleted": false,
"Patch": "--- a/VERSION\\ +++ b/VERSION\\ @@ -1 +1 @@\\ -1.9.7\\ +1.9.8"
}
]
1 change: 1 addition & 0 deletions scm/pr.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ type (
Added bool
Renamed bool
Deleted bool
Patch string
Additions int
Deletions int
Changes int
Expand Down

0 comments on commit d835687

Please sign in to comment.