Skip to content

Commit

Permalink
adding tagversions script with a dedicated bin directory
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanb committed Sep 2, 2010
1 parent d23a62e commit 9467b71
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bash/paths
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export PATH="~/bin:/usr/local/homebrew/bin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/local/git/bin:$PATH"
export PATH="~/bin:~/.bin:/usr/local/homebrew/bin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/local/git/bin:$PATH"
export MANPATH="/usr/local/man:/usr/local/mysql/man:/usr/local/git/man:$MANPATH"
45 changes: 45 additions & 0 deletions bin/tagversions
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env ruby -w

class TagVersions
def initialize(args)
print_help if args.empty?
@regexp = nil
@preview = false
args.each do |argument|
case argument
when '-a', '--all' then @regexp = ".*"
when '-p', '--preview' then @preview = true
when '-h', '--help' then print_help
else @regexp = argument
end
end
end

def print_help
puts <<-HELP
Usage: tagversions [OPTIONS] [REGEXP]
Look through the git commits for messages with the given regular expression and tag what looks like verisons.
Options:
-a, --all Search all commits, not just the ones matching the regular expression.
-p, --preview Don't do actual branching, instead print out what will be tagged.
-h, --help Display this help page.
HELP
exit
end

def run
tags = `git tag`.split("\n")
`git log --pretty="%H %s" | grep "#{@regexp}"`.split("\n").each do |line|
version = line[/\bv?(\d\.[\d\.]*)\b/, 1]
sha = line[/^\w+/]
if version && !version.empty? && !tags.include?(version)
puts "Tagging #{version} on #{sha}"
tags << version
`git tag -a "#{version}" -m "version #{version}" "#{sha}"` unless @preview
end
end
end
end

TagVersions.new($*).run
2 changes: 1 addition & 1 deletion zsh/config
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ else
fi

export EDITOR='mate -w'
export PATH="~/bin:/usr/local/homebrew/bin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/local/git/bin:$PATH"
export PATH="$HOME/bin:$HOME/.bin:/usr/local/homebrew/bin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/local/git/bin:$PATH"
export MANPATH="/usr/local/man:/usr/local/mysql/man:/usr/local/git/man:$MANPATH"

fpath=(~/.zsh/functions $fpath)
Expand Down

0 comments on commit 9467b71

Please sign in to comment.