Skip to content

Commit

Permalink
Fix branch name from Push event
Browse files Browse the repository at this point in the history
- closes #30

Signed-off-by: Tallys Martins <tallysmartins@gmail.com>
  • Loading branch information
tallysmartins committed Jun 21, 2018
1 parent e7d6c50 commit cedaf95
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,22 @@ defmodule ElixirBenchWeb.Github.WebHooks do

defp extract_job_attrs("push", payload) do
slug = get_in(payload, ["repository", "full_name"])
branch_name = get_in(payload, ["ref"])
commit_sha = get_in(payload, ["after"])

branch_name =
case get_in(payload, ["ref"]) do
nil -> nil
name -> String.replace(name, "refs/heads/", "")
end

%{slug: slug, branch_name: branch_name, commit_sha: commit_sha}
end

defp extract_job_attrs("pull_request", payload) do
# data is fetched from sender's repository refered as "head"
slug = get_in(payload, ["pull_request", "head", "repo", "full_name"])
branch_name = get_in(payload, ["pull_request", "head", "ref"])
commit_sha = get_in(payload, ["pull_request", "head", "sha"])
branch_name = get_in(payload, ["pull_request", "head", "ref"])

%{slug: slug, branch_name: branch_name, commit_sha: commit_sha}
end
Expand Down

0 comments on commit cedaf95

Please sign in to comment.