Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added --sha parameter for non-Travis compatibility #36

Merged
merged 1 commit into from
Nov 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ Usage: mix coveralls.post [options] [coveralls-token]
-b (--branch) Branch name ('BRANCH' column at coveralls page)
-c (--committer) Committer name ('COMMITTER' column at coveralls page)
-m (--message) Commit message ('COMMIT' column at coveralls page)
-s (--sha) Commit SHA (required when not using Travis)
```

### [mix coveralls.travis] Post coverage to travis
Expand Down
3 changes: 2 additions & 1 deletion lib/excoveralls/post.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ defmodule ExCoveralls.Post do
defp generate_git_info(options) do
[head: [
committer_name: options[:committer],
message: options[:message]
message: options[:message],
id: options[:sha]
],
branch: options[:branch]
]
Expand Down
3 changes: 2 additions & 1 deletion lib/mix/tasks.ex
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ defmodule Mix.Tasks.Coveralls do
@default_service_name "excoveralls"

def run(args) do
{options, params, _} = OptionParser.parse(args, aliases: [n: :name, b: :branch, c: :committer, m: :message])
{options, params, _} = OptionParser.parse(args, aliases: [n: :name, b: :branch, c: :committer, m: :message, s: :sha])

if Enum.count(params) <= 1 do
Mix.Tasks.Coveralls.do_run(args,
Expand All @@ -109,6 +109,7 @@ defmodule Mix.Tasks.Coveralls do
service_name: extract_service_name(options),
branch: options[:branch] || "",
committer: options[:committer] || "",
sha: options[:sha] || "",
message: options[:message] || "[no commit message]" ])
else
raise %ExCoveralls.InvalidOptionError{message: "Parameter format is invalid"}
Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"idna": {:hex, :idna, "1.0.2"},
"jsx": {:hex, :jsx, "2.4.0"},
"meck": {:hex, :meck, "0.8.2"},
"mock": {:git, "git://github.com/parroty/mock.git", "33d095a9b028f9f97f6d506ae6b2feb34630fdc5", [ref: "fix"]},
"mock": {:git, "https://github.com/parroty/mock.git", "33d095a9b028f9f97f6d506ae6b2feb34630fdc5", [ref: "fix"]},
"ssl_verify_hostname": {:hex, :ssl_verify_hostname, "1.0.4"}}
4 changes: 2 additions & 2 deletions test/mix/tasks_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ defmodule Mix.Tasks.CoverallsTest do
System.put_env("COVERALLS_REPO_TOKEN", "dummy_token")
System.put_env("COVERALLS_SERVICE_NAME", "dummy_service_name")

args = ["-b", "branch", "-c", "committer", "-m", "message"]
args = ["-b", "branch", "-c", "committer", "-m", "message", "-s", "asdf"]
Mix.Tasks.Coveralls.Post.run(args)
assert(called Mix.Task.run("test", ["--cover"]))
assert(ExCoveralls.ConfServer.get ==
[type: "post", endpoint: nil, token: "dummy_token",
service_name: "dummy_service_name", branch: "branch",
committer: "committer", message: "message", args: []])
committer: "committer", sha: "asdf", message: "message", args: []])

System.put_env("COVERALLS_REPO_TOKEN", org_token)
System.put_env("COVERALLS_SERVICE_NAME", org_name)
Expand Down
4 changes: 2 additions & 2 deletions test/post_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ defmodule ExCoveralls.PostTest do

test_with_mock "generate json", System, [cmd: fn(_, _) -> "" end] do

assert(Post.generate_json(@source_info, [token: "1234567890", service_name: "local", branch: "", committer: "", message: ""]) ==
assert(Post.generate_json(@source_info, [token: "1234567890", service_name: "local", branch: "", committer: "", message: "", sha: ""]) ==
"{\"repo_token\":\"1234567890\"," <>
"\"service_name\":\"local\"," <>
"\"source_files\":" <>
"[{\"name\":\"test/fixtures/test.ex\"," <>
"\"source\":\"defmodule Test do\\n def test do\\n end\\nend\\n\"," <>
"\"coverage\":[0,1,null,null]}]," <>
"\"git\":{\"head\":{\"committer_name\":\"\",\"message\":\"\"},\"branch\":\"\"}}"
"\"git\":{\"head\":{\"committer_name\":\"\",\"message\":\"\",\"id\":\"\"},\"branch\":\"\"}}"
)
end
end