git-ticket 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +23 -0
- data/LICENSE +20 -0
- data/README +21 -0
- data/Rakefile +19 -0
- data/VERSION +1 -0
- data/bin/git-ticket +86 -0
- metadata +69 -0
data/.document
ADDED
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
## MAC OS
|
2
|
+
.DS_Store
|
3
|
+
|
4
|
+
## TEXTMATE
|
5
|
+
*.tmproj
|
6
|
+
tmtags
|
7
|
+
|
8
|
+
## EMACS
|
9
|
+
*~
|
10
|
+
\#*
|
11
|
+
.\#*
|
12
|
+
|
13
|
+
## VIM
|
14
|
+
*.swp
|
15
|
+
|
16
|
+
## PROJECT::GENERAL
|
17
|
+
coverage
|
18
|
+
rdoc
|
19
|
+
pkg
|
20
|
+
|
21
|
+
## PROJECT::SPECIFIC
|
22
|
+
# Because I'm right and Yehuda is wrong.
|
23
|
+
*.gemspec
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Rein Henrichs
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Usage: git-ticket [OPTION] TICKET
|
2
|
+
|
3
|
+
Checkout, create, delete or list ticket branches.
|
4
|
+
|
5
|
+
Based on the git workflow described in
|
6
|
+
http://reinh.com/blog/2009/03/02/a-git-workflow-for-agile-teams.html
|
7
|
+
|
8
|
+
NOTE: Currently designed to work with Redmine only.
|
9
|
+
|
10
|
+
Synopsis:
|
11
|
+
git ticket <ticket>
|
12
|
+
git ticket [-i, --interactive] (-b, --branch) <ticket>
|
13
|
+
git ticket (-d, --delete) <ticket>
|
14
|
+
git ticket (-l, --list)
|
15
|
+
|
16
|
+
Options:
|
17
|
+
-i, --interactive Interactive mode.
|
18
|
+
-b, --branch Create a new ticket branch.
|
19
|
+
-d, --delete Delete a ticket branch.
|
20
|
+
-l, --list List all ticket branches.
|
21
|
+
-h, --help You're reading it.
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "git-ticket"
|
8
|
+
gem.summary = %Q{Checkout, create, delete or list ticket branches}
|
9
|
+
gem.description = gem.summary
|
10
|
+
gem.email = "reinh@reinh.com"
|
11
|
+
gem.homepage = "http://github.com/reinh/git-ticket"
|
12
|
+
gem.authors = ["Rein Henrichs"]
|
13
|
+
end
|
14
|
+
Jeweler::GemcutterTasks.new
|
15
|
+
rescue LoadError
|
16
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
17
|
+
end
|
18
|
+
|
19
|
+
task :default => :build
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/bin/git-ticket
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'nokogiri'
|
4
|
+
require 'readline'
|
5
|
+
|
6
|
+
trap('INT') { abort "Exiting..."}
|
7
|
+
|
8
|
+
URL = "http://projects.reductivelabs.com/issues/%d.xml"
|
9
|
+
|
10
|
+
# Flags
|
11
|
+
help = ARGV.delete('--help') || ARGV.delete('-h') || ARGV.empty?
|
12
|
+
branch = ARGV.delete('--branch') || ARGV.delete('-b')
|
13
|
+
interactive = ARGV.delete('--interactive') || ARGV.delete('-i')
|
14
|
+
delete = ARGV.delete('--delete') || ARGV.delete('-d')
|
15
|
+
list = ARGV.delete('--list') || ARGV.delete('-l')
|
16
|
+
|
17
|
+
if help
|
18
|
+
puts <<USAGE
|
19
|
+
Usage: git-ticket [OPTION] TICKET
|
20
|
+
|
21
|
+
Checkout, create, delete or list ticket branches.
|
22
|
+
|
23
|
+
Based on the git workflow described in
|
24
|
+
http://reinh.com/blog/2009/03/02/a-git-workflow-for-agile-teams.html
|
25
|
+
|
26
|
+
NOTE: Currently designed to work with Redmine only.
|
27
|
+
|
28
|
+
Synopsis:
|
29
|
+
git ticket <ticket>
|
30
|
+
git ticket [-i, --interactive] (-b, --branch) <ticket>
|
31
|
+
git ticket (-d, --delete) <ticket>
|
32
|
+
git ticket (-l, --list)
|
33
|
+
|
34
|
+
Options:
|
35
|
+
-i, --interactive Interactive mode.
|
36
|
+
-b, --branch Create a new ticket branch.
|
37
|
+
-d, --delete Delete a ticket branch.
|
38
|
+
-l, --list List all ticket branches.
|
39
|
+
-h, --help You're reading it.
|
40
|
+
USAGE
|
41
|
+
|
42
|
+
exit 0
|
43
|
+
end
|
44
|
+
|
45
|
+
if list
|
46
|
+
branches = `git branch`.gsub(/^\*?\s+/,'').split(/\n/).grep(/^(?:bug\-)?\d+\-/)
|
47
|
+
puts branches.empty? ? "No ticket branches" : branches
|
48
|
+
exit 0
|
49
|
+
end
|
50
|
+
|
51
|
+
id = ARGV.grep(/^\d+$/).first.to_i
|
52
|
+
|
53
|
+
if branch
|
54
|
+
doc = Nokogiri::XML(`curl -s #{URL % id}`)
|
55
|
+
|
56
|
+
type = doc.search('issue tracker').first['name'].downcase
|
57
|
+
title = doc.search('issue subject').first.text.gsub(/\s+/, '-')
|
58
|
+
|
59
|
+
branch_name_root = "#{'bug-' if type=="bug"}#{id}-"
|
60
|
+
branch_name = "#{branch_name_root}#{title}".downcase
|
61
|
+
def branch_name.too_long?; length > 50 end
|
62
|
+
|
63
|
+
|
64
|
+
if interactive || branch_name.too_long?
|
65
|
+
puts "Branch name: #{branch_name}"
|
66
|
+
new_branch_name = Readline.readline "New branch name: #{branch_name_root}"
|
67
|
+
branch_name = branch_name_root + new_branch_name unless new_branch_name.empty?
|
68
|
+
end
|
69
|
+
|
70
|
+
`git checkout -b #{branch_name}`
|
71
|
+
exit 0
|
72
|
+
end
|
73
|
+
|
74
|
+
existing_branch = `git branch`.gsub(/^\*?\s+/,'').split(/\n/).grep(/^(?:bug\-)?#{id}\-/)
|
75
|
+
|
76
|
+
if existing_branch.empty?
|
77
|
+
puts "No such ticket branch"
|
78
|
+
exit 0
|
79
|
+
end
|
80
|
+
|
81
|
+
if delete
|
82
|
+
puts `git branch -d #{existing_branch}`
|
83
|
+
exit 0
|
84
|
+
end
|
85
|
+
|
86
|
+
`git checkout #{existing_branch}`
|
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: git-ticket
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Rein Henrichs
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-04-22 00:00:00 -07:00
|
18
|
+
default_executable: git-ticket
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: Checkout, create, delete or list ticket branches
|
22
|
+
email: reinh@reinh.com
|
23
|
+
executables:
|
24
|
+
- git-ticket
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files:
|
28
|
+
- LICENSE
|
29
|
+
- README
|
30
|
+
files:
|
31
|
+
- .document
|
32
|
+
- .gitignore
|
33
|
+
- LICENSE
|
34
|
+
- README
|
35
|
+
- Rakefile
|
36
|
+
- VERSION
|
37
|
+
- bin/git-ticket
|
38
|
+
has_rdoc: true
|
39
|
+
homepage: http://github.com/reinh/git-ticket
|
40
|
+
licenses: []
|
41
|
+
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options:
|
44
|
+
- --charset=UTF-8
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
segments:
|
52
|
+
- 0
|
53
|
+
version: "0"
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
61
|
+
requirements: []
|
62
|
+
|
63
|
+
rubyforge_project:
|
64
|
+
rubygems_version: 1.3.6
|
65
|
+
signing_key:
|
66
|
+
specification_version: 3
|
67
|
+
summary: Checkout, create, delete or list ticket branches
|
68
|
+
test_files: []
|
69
|
+
|