Class: MyScripts::Gitto
- Defined in:
- lib/my_scripts/scripts/gitto.rb
Overview
This script wraps up all work done on project in current directory, adds all new(unversioned) files to git, commits all work done so far, optionally bumps project version and pushes changes to remote repo
Constant Summary collapse
- VERSION =
'0.1.0'
- COMMAND_PATTERN =
/^(\d+\.\d+\.\d+ # either explicit version (1.2.3) (?:\.(.*?))? # possibly followed by .build |\.(.*?) # or, just .build |\d{1}0{0,2})$/x
Instance Method Summary collapse
-
#run ⇒ Object
or, one digit followed by 0-2 zeroes (100/10/1 - bump major/minor/patch).
Methods inherited from Script
#error, #gets, #initialize, #puts, #system, #to_s, #usage, #version
Constructor Details
This class inherits a constructor from MyScripts::Script
Instance Method Details
#run ⇒ Object
or, one digit followed by 0-2 zeroes (100/10/1 - bump major/minor/patch)
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/my_scripts/scripts/gitto.rb', line 14 def run usage "[0.1.2 - version, 100/10/1 - bump major/minor/patch, .build - add build] Commit message goes here" if @argv.empty? # First Arg may indicate version command if it matches pattern version_command = @argv[0] =~ COMMAND_PATTERN ? @argv.shift : nil # All the other args lumped into message, or default message if @argv.empty? = "Commit #{Time.now.to_s[0..-6]}" = nil else = = @argv.join(' ') end # Updating version only if version command set if version_command puts "Updating version with #{version_command}" if system %Q{rake "version[#{version_command},#{}]"} else system %Q{rake version[#{version_command}]} end end puts "Adding all the changes" system "git add --all" puts "Committing everything with message: #{}" system %Q[git commit -a -m "#{}" --author arvicco] current_branch = `git branch`.strip puts "Pushing to (default) remote for branch: #{current_branch}" system "git push" end |