Module: CIRunner::GitHelper
Overview
A helper for the ‘ci_runner rerun` command to infer options automatically. The goal being to have the user only type `ci_runner rerun` and have things work magically.
The command line options passed by a user have precedence.
Instance Method Summary collapse
-
#head_commit ⇒ String
Get the HEAD commit of the repository.
-
#repository_from_remote ⇒ String
Get the full repository name (including the owner, i.e. rails/rails) thanks to the Git remote.
Instance Method Details
#head_commit ⇒ String
Get the HEAD commit of the repository. This assumes the user runs the ‘ci-runner` command from a repository.
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ci_runner/git_helper.rb', line 19 def head_commit stdout, _, status = Open3.capture3("git rev-parse HEAD") if status.success? stdout.rstrip else raise(Error, <<~EOM) Couldn't determine the commit. The commit is required to download the right CI logs. Please pass the `--commit` flag (ci_runner --commit <commit>) EOM end end |
#repository_from_remote ⇒ String
Get the full repository name (including the owner, i.e. rails/rails) thanks to the Git remote. This allows the user to not have to type ‘ci-runner rerun –repostitory catanacorp/catana` each time.
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/ci_runner/git_helper.rb', line 39 def repository_from_remote stdout, _, status = Open3.capture3("git remote -v") if status.success? process_remotes(stdout) else raise(Error, <<~EOM) Couldn't determine the name of the repository. Please pass the `--repository` flag (ci_runner --repository <owner/repository_name>) EOM end end |