forked from ryanb/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding tagversions script with a dedicated bin directory
- Loading branch information
Showing
3 changed files
with
47 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters