Class: Thrust::Git
- Inherits:
-
Object
- Object
- Thrust::Git
- Defined in:
- lib/thrust/git.rb
Instance Method Summary collapse
- #checkout_file(filename) ⇒ Object
- #commit_summary_for_last_deploy(deployment_target) ⇒ Object
- #current_commit ⇒ Object
- #ensure_clean ⇒ Object
- #generate_notes_for_deployment(deployment_target) ⇒ Object
-
#initialize(out) ⇒ Git
constructor
A new instance of Git.
- #reset ⇒ Object
Constructor Details
#initialize(out) ⇒ Git
Returns a new instance of Git.
4 5 6 |
# File 'lib/thrust/git.rb', line 4 def initialize(out) @out = out end |
Instance Method Details
#checkout_file(filename) ⇒ Object
25 26 27 |
# File 'lib/thrust/git.rb', line 25 def checkout_file(filename) Thrust::Executor.system_or_exit("git checkout #{filename}") end |
#commit_summary_for_last_deploy(deployment_target) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/thrust/git.rb', line 29 def commit_summary_for_last_deploy(deployment_target) sha_of_latest_deployed_commit = latest_deployed_commit(deployment_target) if sha_of_latest_deployed_commit "#{deployment_target}:".blue + " #{summary_for_commit(sha_of_latest_deployed_commit)}" else "#{deployment_target}:".blue + ' Never deployed' end end |
#current_commit ⇒ Object
17 18 19 |
# File 'lib/thrust/git.rb', line 17 def current_commit Thrust::Executor.capture_output_from_system('git log --format=format:%h -1').strip end |
#ensure_clean ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/thrust/git.rb', line 8 def ensure_clean if ENV['IGNORE_GIT'] @out.puts 'WARNING NOT CHECKING FOR CLEAN WORKING DIRECTORY'.red else @out.puts 'Checking for clean working tree...' Thrust::Executor.system_or_exit 'git diff-index --quiet HEAD' end end |
#generate_notes_for_deployment(deployment_target) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/thrust/git.rb', line 38 def generate_notes_for_deployment(deployment_target) sha_of_latest_commit = Thrust::Executor.capture_output_from_system('git rev-parse HEAD').strip sha_of_latest_deployed_commit = latest_deployed_commit(deployment_target) notes = Tempfile.new('deployment_notes') if sha_of_latest_deployed_commit Thrust::Executor.system_or_exit("git log --oneline #{sha_of_latest_deployed_commit}...#{sha_of_latest_commit}", notes.path) else notes.puts(summary_for_commit(sha_of_latest_commit)) notes.close end notes.path end |
#reset ⇒ Object
21 22 23 |
# File 'lib/thrust/git.rb', line 21 def reset Thrust::Executor.system_or_exit('git reset --hard') end |