git-fogbugz 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 +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +18 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/bin/git-fogbugz +7 -0
- data/lib/git_fogbugz.rb +194 -0
- data/test/helper.rb +9 -0
- data/test/test_git-fogbugz.rb +7 -0
- metadata +75 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Roy W. Black
|
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.rdoc
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
= git-fogbugz
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Note on Patches/Pull Requests
|
6
|
+
|
7
|
+
* Fork the project.
|
8
|
+
* Make your feature addition or bug fix.
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
10
|
+
future version unintentionally.
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
12
|
+
(if you want to have your own version, that is fine but
|
13
|
+
bump version in a commit by itself I can ignore when I pull)
|
14
|
+
* Send me a pull request. Bonus points for topic branches.
|
15
|
+
|
16
|
+
== Copyright
|
17
|
+
|
18
|
+
Copyright (c) 2009 Roy W. Black. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "git-fogbugz"
|
8
|
+
gem.summary = %Q{Log git pushes to fogbugz}
|
9
|
+
gem.description = %Q{Log git pushes to fogbugz}
|
10
|
+
gem.email = "roy@roywblack.com"
|
11
|
+
gem.homepage = "http://github.com/roywblack/git-fogbugz"
|
12
|
+
gem.authors = ["Roy W. Black"]
|
13
|
+
gem.add_dependency('grit', '>= 2.0.0')
|
14
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
|
+
end
|
16
|
+
Jeweler::GemcutterTasks.new
|
17
|
+
rescue LoadError
|
18
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'rake/testtask'
|
22
|
+
Rake::TestTask.new(:test) do |test|
|
23
|
+
test.libs << 'lib' << 'test'
|
24
|
+
test.pattern = 'test/**/test_*.rb'
|
25
|
+
test.verbose = true
|
26
|
+
end
|
27
|
+
|
28
|
+
begin
|
29
|
+
require 'rcov/rcovtask'
|
30
|
+
Rcov::RcovTask.new do |test|
|
31
|
+
test.libs << 'test'
|
32
|
+
test.pattern = 'test/**/test_*.rb'
|
33
|
+
test.verbose = true
|
34
|
+
end
|
35
|
+
rescue LoadError
|
36
|
+
task :rcov do
|
37
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
task :test => :check_dependencies
|
42
|
+
|
43
|
+
task :default => :test
|
44
|
+
|
45
|
+
require 'rake/rdoctask'
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
47
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
|
+
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = "git-fogbugz #{version}"
|
51
|
+
rdoc.rdoc_files.include('README*')
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/bin/git-fogbugz
ADDED
data/lib/git_fogbugz.rb
ADDED
@@ -0,0 +1,194 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# == Synopsis
|
4
|
+
# git post-receive hook for integration with FogBugz
|
5
|
+
#
|
6
|
+
# == Examples
|
7
|
+
# This command takes standard input from git's post-receive hook
|
8
|
+
# git-fogbugz foo.txt
|
9
|
+
#
|
10
|
+
# Other examples:
|
11
|
+
# git-fogbugz --passthrough
|
12
|
+
#
|
13
|
+
# == Usage
|
14
|
+
# git-fogbugz [options] source_file
|
15
|
+
#
|
16
|
+
# For help use: git-fogbugz -h
|
17
|
+
#
|
18
|
+
# == Options
|
19
|
+
# -h, --help Displays help message
|
20
|
+
# -v, --version Display the version, then exit
|
21
|
+
# -q, --quiet Output as little as possible, overrides verbose
|
22
|
+
# -V, --verbose Verbose output
|
23
|
+
# -p, --passthrough Push stdtin to stdout for chaining
|
24
|
+
#
|
25
|
+
# == Author
|
26
|
+
# Roy W. Black
|
27
|
+
#
|
28
|
+
# == Copyright
|
29
|
+
# Copyright (c) 2007 Roy W. Black. Licensed under the MIT License:
|
30
|
+
# http://www.opensource.org/licenses/mit-license.php
|
31
|
+
|
32
|
+
|
33
|
+
require 'optparse'
|
34
|
+
require 'ostruct'
|
35
|
+
require 'date'
|
36
|
+
require 'net/https'
|
37
|
+
require 'uri'
|
38
|
+
require 'grit'
|
39
|
+
include Grit
|
40
|
+
|
41
|
+
class App
|
42
|
+
VERSION = '0.1.0'
|
43
|
+
|
44
|
+
attr_reader :options
|
45
|
+
|
46
|
+
def initialize(arguments, stdin)
|
47
|
+
@arguments = arguments
|
48
|
+
@stdin = stdin
|
49
|
+
|
50
|
+
# Set defaults
|
51
|
+
@options = OpenStruct.new
|
52
|
+
@options.verbose = false
|
53
|
+
@options.quiet = false
|
54
|
+
@options.quiet = false
|
55
|
+
@options.passthrough = false
|
56
|
+
@options.repo = "C:/clients/MattMuresan/source/scenengine"
|
57
|
+
# TO DO - add additional defaults
|
58
|
+
@options.host = "https://onebrave.fogbugz.com"
|
59
|
+
@options.port = 443
|
60
|
+
@options.repo_id = 4
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
# Parse options, check arguments, then process the command
|
65
|
+
def run
|
66
|
+
|
67
|
+
if parsed_options? && arguments_valid?
|
68
|
+
|
69
|
+
$stderr.puts "Start at #{DateTime.now}\n\n" if @options.verbose
|
70
|
+
|
71
|
+
output_options if @options.verbose # [Optional]
|
72
|
+
|
73
|
+
process_arguments
|
74
|
+
process_command
|
75
|
+
|
76
|
+
$stderr.puts "\nFinished at #{DateTime.now}" if @options.verbose
|
77
|
+
|
78
|
+
else
|
79
|
+
output_usage
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
protected
|
85
|
+
|
86
|
+
def parsed_options?
|
87
|
+
opts = OptionParser.new do |opts|
|
88
|
+
opts.banner = <<BANNER
|
89
|
+
Usage: git-fogbugz [options]
|
90
|
+
|
91
|
+
Options are:
|
92
|
+
BANNER
|
93
|
+
opts.separator ""
|
94
|
+
opts.on_tail('-r', '--repo=REPO') {|repo| @options.repo = repo }
|
95
|
+
opts.on_tail('-v', '--version') { output_version ; exit 0 }
|
96
|
+
opts.on_tail('-V', '--verbose') { @options.verbose = true }
|
97
|
+
opts.on_tail('-q', '--quiet') { @options.quiet = true }
|
98
|
+
opts.on('-p', '--passthrough'){ @options.passthrough = true }
|
99
|
+
|
100
|
+
opts.on_tail('-h', '--help') { output_version; puts opts; exit 0 }
|
101
|
+
end
|
102
|
+
opts.parse!(@arguments) rescue return false
|
103
|
+
process_options
|
104
|
+
true
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
# Performs post-parse processing on options
|
109
|
+
def process_options
|
110
|
+
@options.verbose = false if @options.quiet
|
111
|
+
end
|
112
|
+
|
113
|
+
def output_options
|
114
|
+
$stderr.puts "Options:\n"
|
115
|
+
|
116
|
+
@options.marshal_dump.each do |name, val|
|
117
|
+
$stderr.puts " #{name} = #{val}"
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
# True if required arguments were provided
|
122
|
+
def arguments_valid?
|
123
|
+
# TO DO - implement your real logic here
|
124
|
+
#true if @arguments.length == 1
|
125
|
+
true
|
126
|
+
end
|
127
|
+
|
128
|
+
# Setup the arguments
|
129
|
+
def process_arguments
|
130
|
+
# TO DO - place in local vars, etc
|
131
|
+
end
|
132
|
+
|
133
|
+
def output_help
|
134
|
+
output_version
|
135
|
+
#RDoc::usage() #exits app
|
136
|
+
end
|
137
|
+
|
138
|
+
def output_usage
|
139
|
+
puts @options
|
140
|
+
#RDoc::usage('usage') # gets usage from comments above
|
141
|
+
end
|
142
|
+
|
143
|
+
def output_version
|
144
|
+
puts "#{File.basename(__FILE__)} version #{VERSION}"
|
145
|
+
end
|
146
|
+
|
147
|
+
def process_command
|
148
|
+
# TO DO - do whatever this app does
|
149
|
+
|
150
|
+
process_standard_input # [Optional]
|
151
|
+
end
|
152
|
+
|
153
|
+
def process_standard_input
|
154
|
+
repo = Repo.new(@options.repo)
|
155
|
+
#input = @stdin.read
|
156
|
+
# TO DO - process input
|
157
|
+
# [Optional]
|
158
|
+
@stdin.each do |line|
|
159
|
+
old, new, ref = line.split
|
160
|
+
repo.commits_between(old, new).each do |commit|
|
161
|
+
process_commit(commit)
|
162
|
+
end
|
163
|
+
$stdout.puts line if @options.passthrough
|
164
|
+
# TO DO - process each line
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
private
|
169
|
+
def process_commit(commit)
|
170
|
+
uri = URI.parse(@options.host)
|
171
|
+
fogbugz = Net::HTTP.new(uri.host, uri.port)
|
172
|
+
if uri.scheme == "https"
|
173
|
+
fogbugz.use_ssl=true
|
174
|
+
fogbugz.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
175
|
+
end
|
176
|
+
if commit.message =~ /(bugzid|case|issue)[:\s]+(\d+)/i
|
177
|
+
id = commit.id[0,7]
|
178
|
+
files = commit.diffs.each do |d|
|
179
|
+
resp = fogbugz.get(make_url($2, '00000', id, d.a_path))
|
180
|
+
#puts resp.body
|
181
|
+
end
|
182
|
+
end
|
183
|
+
return
|
184
|
+
end
|
185
|
+
|
186
|
+
def make_url(bug_id, old, new, file)
|
187
|
+
"/cvsSubmit.asp?ixBug=#{bug_id}&sFile=#{file}&sPrev=#{old}&sNew=#{new}&ixRepository=#{@options.repo_id}"
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
|
192
|
+
# TO DO - Add your Modules, Classes, etc
|
193
|
+
|
194
|
+
|
data/test/helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: git-fogbugz
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Roy W. Black
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-11-19 00:00:00 -05:00
|
13
|
+
default_executable: git-fogbugz
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: grit
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.0.0
|
24
|
+
version:
|
25
|
+
description: Log git pushes to fogbugz
|
26
|
+
email: roy@roywblack.com
|
27
|
+
executables:
|
28
|
+
- git-fogbugz
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- LICENSE
|
33
|
+
- README.rdoc
|
34
|
+
files:
|
35
|
+
- .document
|
36
|
+
- .gitignore
|
37
|
+
- LICENSE
|
38
|
+
- README.rdoc
|
39
|
+
- Rakefile
|
40
|
+
- VERSION
|
41
|
+
- bin/git-fogbugz
|
42
|
+
- lib/git_fogbugz.rb
|
43
|
+
- test/helper.rb
|
44
|
+
- test/test_git-fogbugz.rb
|
45
|
+
has_rdoc: true
|
46
|
+
homepage: http://github.com/roywblack/git-fogbugz
|
47
|
+
licenses: []
|
48
|
+
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options:
|
51
|
+
- --charset=UTF-8
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: "0"
|
59
|
+
version:
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: "0"
|
65
|
+
version:
|
66
|
+
requirements: []
|
67
|
+
|
68
|
+
rubyforge_project:
|
69
|
+
rubygems_version: 1.3.5
|
70
|
+
signing_key:
|
71
|
+
specification_version: 3
|
72
|
+
summary: Log git pushes to fogbugz
|
73
|
+
test_files:
|
74
|
+
- test/helper.rb
|
75
|
+
- test/test_git-fogbugz.rb
|