Sha256: f00d40eb3d062c3271e6fae2decd7241197d2d0ea9fc8570e2a76452be85a1dc

Contents?: true

Size: 1.8 KB

Versions: 6

Compression:

Stored size: 1.8 KB

Contents

module MyScripts
  # 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
  #
  class Gitto < Script
    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  # or, one digit followed by 0-2 zeroes (100/10/1 - bump major/minor/patch)

    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_message = "Commit #{Time.now.to_s[0..-6]}"
        history_message = nil
      else
        commit_message = history_message = @argv.join(' ')
      end

      # Updating version only if version command set
      if version_command
        puts "Updating version with #{version_command}"
        if history_message
          system %Q{rake "version[#{version_command},#{history_message}]"}
        else
          system %Q{rake version[#{version_command}]}
        end
      end

      puts "Adding all the changes"
      system %Q{git add --all}

      puts "Committing everything with message: #{commit_message}"
      system %Q{git commit -a -m "#{commit_message}" --author arvicco}

      current_branch = `git branch`.strip
      puts "Pushing to (default) remote for branch: #{current_branch}"
      system %Q{git push}
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
my_scripts-0.1.14 lib/my_scripts/scripts/gitto.rb
my_scripts-0.1.13 lib/my_scripts/scripts/gitto.rb
my_scripts-0.1.12 lib/my_scripts/scripts/gitto.rb
my_scripts-0.1.11 lib/my_scripts/scripts/gitto.rb
my_scripts-0.1.10 lib/my_scripts/scripts/gitto.rb
my_scripts-0.1.9 lib/my_scripts/scripts/gitto.rb