Skip to content

Commit

Permalink
Merge pull request #113 from tphoney/DRON-88
Browse files Browse the repository at this point in the history
(DRON-88) github fix pr ListChanges deleted/renamed status
  • Loading branch information
TP Honey authored Jun 16, 2021
2 parents 84b3706 + 4927313 commit f685c90
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 13 deletions.
4 changes: 2 additions & 2 deletions scm/driver/github/pr.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ func convertChange(from *file) *scm.Change {
return &scm.Change{
Path: from.Filename,
Added: from.Status == "added",
Deleted: from.Status == "deleted",
Renamed: from.Status == "moved",
Deleted: from.Status == "removed",
Renamed: from.Status == "renamed",
BlobID: from.BlobID,
}
}
54 changes: 45 additions & 9 deletions scm/driver/github/testdata/pr_files.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,50 @@
[
{
"sha": "bbcd538c8e72b8c175046e27cc8f907076331401",
"filename": "file1.txt",
"sha": "291b15982c4926705f5639abffe96b2b6c419ce7",
"filename": "asda2",
"status": "modified",
"additions": 1,
"deletions": 1,
"changes": 2,
"blob_url": "https://github.com/tphoney/scm-test/blob/ad442ec8e99589912117c7d1e689f56b32356868/asda2",
"raw_url": "https://github.com/tphoney/scm-test/raw/ad442ec8e99589912117c7d1e689f56b32356868/asda2",
"contents_url": "https://api.github.com/repos/tphoney/scm-test/contents/asda2?ref=ad442ec8e99589912117c7d1e689f56b32356868",
"patch": "@@ -1,2 +1,2 @@n-n+asdasdn asdasdasd"
},
{
"sha": "ce013625030ba8dba906f756967f9e9ca394464a",
"filename": "remove_me",
"status": "added",
"additions": 103,
"deletions": 21,
"changes": 124,
"blob_url": "https://github.com/octocat/Hello-World/blob/6dcb09b5b57875f334f61aebed695e2e4193db5e/file1.txt",
"raw_url": "https://github.com/octocat/Hello-World/raw/6dcb09b5b57875f334f61aebed695e2e4193db5e/file1.txt",
"contents_url": "https://api.github.com/repos/octocat/Hello-World/contents/file1.txt?ref=6dcb09b5b57875f334f61aebed695e2e4193db5e",
"patch": "@@ -132,7 +132,7 @@ module Test @@ -1000,7 +1000,7 @@ module Test"
"additions": 1,
"deletions": 0,
"changes": 1,
"blob_url": "https://github.com/tphoney/scm-test/blob/ad442ec8e99589912117c7d1e689f56b32356868/remove_me",
"raw_url": "https://github.com/tphoney/scm-test/raw/ad442ec8e99589912117c7d1e689f56b32356868/remove_me",
"contents_url": "https://api.github.com/repos/tphoney/scm-test/contents/remove_me?ref=ad442ec8e99589912117c7d1e689f56b32356868",
"patch": "@@ -0,0 +1 @@n+hello"
},
{
"sha": "70c379b63ffa0795fdbfbc128e5a2818397b7ef8",
"filename": "tp",
"status": "renamed",
"additions": 0,
"deletions": 0,
"changes": 0,
"blob_url": "https://github.com/tphoney/scm-test/blob/ad442ec8e99589912117c7d1e689f56b32356868/tp",
"raw_url": "https://github.com/tphoney/scm-test/raw/ad442ec8e99589912117c7d1e689f56b32356868/tp",
"contents_url": "https://api.github.com/repos/tphoney/scm-test/contents/tp?ref=ad442ec8e99589912117c7d1e689f56b32356868",
"previous_filename": "abhinav"
},
{
"sha": "0f9282d7e71e0f8cb748bfe00e52d7ed13dad036",
"filename": "upsert",
"status": "removed",
"additions": 0,
"deletions": 1,
"changes": 1,
"blob_url": "https://github.com/tphoney/scm-test/blob/6a86c7aca4425c8781876c31ffb6e4284fb07d56/upsert",
"raw_url": "https://github.com/tphoney/scm-test/raw/6a86c7aca4425c8781876c31ffb6e4284fb07d56/upsert",
"contents_url": "https://api.github.com/repos/tphoney/scm-test/contents/upsert?ref=6a86c7aca4425c8781876c31ffb6e4284fb07d56",
"patch": "@@ -1 +0,0 @@n-asdasn No newline at end of file"
}
]
25 changes: 23 additions & 2 deletions scm/driver/github/testdata/pr_files.json.golden
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
[
{
"Path": "file1.txt",
"Path": "asda2",
"Added": false,
"Renamed": false,
"Deleted": false,
"BlobID": "291b15982c4926705f5639abffe96b2b6c419ce7"
},
{
"Path": "remove_me",
"Added": true,
"Renamed": false,
"Deleted": false,
"BlobID": "bbcd538c8e72b8c175046e27cc8f907076331401"
"BlobID": "ce013625030ba8dba906f756967f9e9ca394464a"
},
{
"Path": "tp",
"Added": false,
"Renamed": true,
"Deleted": false,
"BlobID": "70c379b63ffa0795fdbfbc128e5a2818397b7ef8"
},
{
"Path": "upsert",
"Added": false,
"Renamed": false,
"Deleted": true,
"BlobID": "0f9282d7e71e0f8cb748bfe00e52d7ed13dad036"
}
]

0 comments on commit f685c90

Please sign in to comment.