GitHub push event for a push to a new branch set Created to true and GopherCI incorrectly detects this as a first commit it a new repository:
|
// PushConfig returns an AnalyseConfig for a GitHub Push Event. |
|
func PushConfig(e *github.PushEvent) AnalyseConfig { |
|
// commitFrom is after~numCommits for the same reason as baseRef but |
|
// also because first pushes's before is 000000.... which can't be |
|
// used in api request |
|
commitFrom := fmt.Sprintf("%v~%v", *e.After, len(e.Commits)) |
|
if e.Created != nil && *e.Created { |
|
commitFrom = "" |
|
} |
So when a push to a new branch occurs, we blank the commitFrom as a way of telling other API calls, that there was no previous diff. This is true for a new repository, but not for a new branch on an existing repository (with a shared tree?). The push event still has a compare URL using ^ to indicate a comparison between the first commit's parent and the latest commit.
Example push to a new branch dev (Delivery ID: 9bf33710-8164-11e7-864b-47facb9a6108):
{
"ref": "refs/heads/dev",
"before": "0000000000000000000000000000000000000000",
"after": "f67",
"created": true,
"deleted": false,
"forced": false,
"base_ref": null,
"compare": "https://github.com/owner/repo/compare/d5ed^...f67",
"commits": [
{
"id": "d5ed",
"tree_id": "91b5c",
"distinct": true,
"message": "",
"timestamp": "",
"url": "https://github.com/owner/repo/commit/d5ed",
"author": {
},
"committer": {
},
"added": [
],
"removed": [
],
"modified": [
"main.go"
]
},
{
"id": "36a1",
"tree_id": "2f10",
"distinct": true,
"message": "",
"timestamp": "",
"url": "https://github.com/owner/repo/commit/36a",
"author": {
},
"committer": {
},
"added": [
],
"removed": [
],
"modified": [
"main.go"
]
},
{
"id": "f67",
"tree_id": "f22",
"distinct": true,
"message": "",
"timestamp": "",
"url": "https://github.com/owner/repo/commit/f67",
"author": {
},
"committer": {
},
"added": [
],
"removed": [
],
"modified": [
"main.go"
]
}
],
"head_commit": {
"id": "f67",
"tree_id": "f22",
"distinct": true,
"message": "",
"timestamp": "",
"url": "https://github.com/owner/repo/commit/f67",
"author": {
},
"committer": {
},
"added": [
],
"removed": [
],
"modified": [
"main.go"
]
},
"repository": {
},
"pusher": {
},
"sender": {
},
"installation": {
"id":
}
}
Example push to a new repository (Delivery ID: ff8bc440-80e7-11e7-8913-69c56684fd07):
{
"ref": "refs/heads/master",
"before": "0000000000000000000000000000000000000000",
"after": "5263ba3517f5b1ed8dee3c721ac7217fcba66cb2",
"created": true,
"deleted": false,
"forced": false,
"base_ref": null,
"compare": "https://github.com/bradleyfalzon/dep-case-collision/commit/5263ba3517f5",
"commits": [
{
"id": "5263ba3517f5b1ed8dee3c721ac7217fcba66cb2",
"tree_id": "a0b3e38811d80665fc0b7884cc47cb4b06a14c8e",
"distinct": true,
"message": "Initial commit",
"timestamp": "2017-08-14T21:28:26+09:30",
"url": "https://github.com/bradleyfalzon/dep-case-collision/commit/5263ba3517f5b1ed8dee3c721ac7217fcba66cb2",
"author": {
},
"committer": {
},
"added": [
"README.md",
"foo.go"
],
"removed": [
],
"modified": [
]
}
],
"head_commit": {
"id": "5263ba3517f5b1ed8dee3c721ac7217fcba66cb2",
"tree_id": "a0b3e38811d80665fc0b7884cc47cb4b06a14c8e",
"distinct": true,
"message": "Initial commit",
"timestamp": "2017-08-14T21:28:26+09:30",
"url": "https://github.com/bradleyfalzon/dep-case-collision/commit/5263ba3517f5b1ed8dee3c721ac7217fcba66cb2",
"author": {
},
"committer": {
},
"added": [
"README.md",
"foo.go"
],
"removed": [
],
"modified": [
]
},
"repository": {
},
"pusher": {
},
"sender": {
},
"installation": {
"id":
}
}
About the only thing that looks like something I can use is to check if the compare URL contains ^....... 🤔
GitHub push event for a push to a new branch set Created to true and GopherCI incorrectly detects this as a first commit it a new repository:
gopherci/internal/github/handlers.go
Lines 238 to 246 in af52b55
So when a push to a new branch occurs, we blank the
commitFromas a way of telling other API calls, that there was no previous diff. This is true for a new repository, but not for a new branch on an existing repository (with a shared tree?). The push event still has a compare URL using^to indicate a comparison between the first commit's parent and the latest commit.Example push to a new branch
dev(Delivery ID: 9bf33710-8164-11e7-864b-47facb9a6108):Example push to a new repository (Delivery ID: ff8bc440-80e7-11e7-8913-69c56684fd07):
About the only thing that looks like something I can use is to check if the compare URL contains
^....... 🤔