Module: Vtasks::Utils::Git
- Included in:
- Docker::Image, Docker::Image::Build, Puppet, Release
- Defined in:
- lib/vtasks/utils/git.rb
Overview
Git module
Constant Summary collapse
- GITHUB_TOKEN =
ENV['GITHUB_TOKEN']
Instance Method Summary collapse
-
#git_branch ⇒ Object
Get the branch name.
-
#git_ci_status(branch = 'master') ⇒ Object
Get the CI Status (needs hub.github.com/).
-
#git_clean_repo ⇒ Object
Check if the repo is clean.
-
#git_commit ⇒ Object
Get git short commit hash.
-
#git_url ⇒ Object
Get the URL of the origin remote.
Instance Method Details
#git_branch ⇒ Object
Get the branch name
13 14 15 16 17 18 |
# File 'lib/vtasks/utils/git.rb', line 13 def git_branch return ENV['GIT_BRANCH'] if ENV['GIT_BRANCH'] return ENV['TRAVIS_BRANCH'] if ENV['TRAVIS_BRANCH'] return ENV['CIRCLE_BRANCH'] if ENV['CIRCLE_BRANCH'] `git symbolic-ref HEAD --short 2>/dev/null`.strip end |
#git_ci_status(branch = 'master') ⇒ Object
Get the CI Status (needs hub.github.com/)
26 27 28 |
# File 'lib/vtasks/utils/git.rb', line 26 def git_ci_status(branch = 'master') `hub ci-status #{branch}`.strip end |
#git_clean_repo ⇒ Object
Check if the repo is clean
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/vtasks/utils/git.rb', line 31 def git_clean_repo # Check if there are uncommitted changes unless system 'git diff --quiet HEAD' abort('ERROR: Commit your changes first.') end # Check if there are untracked files unless `git ls-files --others --exclude-standard`.to_s.empty? abort('ERROR: There are untracked files.') end true end |
#git_commit ⇒ Object
Get git short commit hash
8 9 10 |
# File 'lib/vtasks/utils/git.rb', line 8 def git_commit `git rev-parse --short HEAD`.strip end |
#git_url ⇒ Object
Get the URL of the origin remote
21 22 23 |
# File 'lib/vtasks/utils/git.rb', line 21 def git_url `git config --get remote.origin.url`.strip end |