Skip to content

Commit

Permalink
fix(git-sidecar): when commit-ref is missing, use commit-id
Browse files Browse the repository at this point in the history
fixes #434, #443
  • Loading branch information
adamreese committed May 10, 2018
1 parent df9e771 commit 4b30fd3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
11 changes: 6 additions & 5 deletions git-sidecar/rootfs/clone.sh
Expand Up @@ -3,14 +3,15 @@ set -euo pipefail

set -x

# The Git reference. Required.
# The Git SHA1 of the revision.
: "${BRIGADE_COMMIT_ID:=}"

# The Git reference.
#
# Also can be a full hex object name.
# master, v0.1.0, refs/pulls/1/head, 589e15029e1e44dee48de4800daf1f78e64287c0
: "${BRIGADE_COMMIT_REF:?}"

# The Git SHA1 of the revision.
: "${BRIGADE_COMMIT_ID:=}"
# If not set, it will try BRIGADE_COMMIT_ID
: "${BRIGADE_COMMIT_REF:=${BRIGADE_COMMIT_ID}}"

# The working directory.
: "${BRIGADE_WORKSPACE:=/src}"
Expand Down
2 changes: 2 additions & 0 deletions pkg/webhook/github.go
Expand Up @@ -131,9 +131,11 @@ func (s *githubHook) handleEvent(c *gin.Context, eventType string) {
case *github.DeploymentEvent:
repo = e.Repo.GetFullName()
rev.Commit = e.Deployment.GetSHA()
rev.Ref = e.Deployment.GetRef()
case *github.DeploymentStatusEvent:
repo = e.Repo.GetFullName()
rev.Commit = e.Deployment.GetSHA()
rev.Ref = e.Deployment.GetRef()
default:
log.Printf("Failed to parse payload")
c.JSON(http.StatusBadRequest, gin.H{"status": "Received data is not valid JSON"})
Expand Down
2 changes: 2 additions & 0 deletions pkg/webhook/github_test.go
Expand Up @@ -125,11 +125,13 @@ func TestGithubHandler(t *testing.T) {
{
event: "deployment",
commit: "9049f1265b7d61be4a8904a9a27120d2064dab3b",
ref: "master",
payloadFile: "testdata/github-deployment-payload.json",
},
{
event: "deployment_status",
commit: "9049f1265b7d61be4a8904a9a27120d2064dab3b",
ref: "master",
payloadFile: "testdata/github-deployment_status-payload.json",
},
}
Expand Down

0 comments on commit 4b30fd3

Please sign in to comment.