git_flow_pivotal 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/git_flow_pivotal.gemspec +19 -0
- data/lib/git_flow_pivotal/railtie.rb +11 -0
- data/lib/git_flow_pivotal/version.rb +3 -0
- data/lib/git_flow_pivotal.rb +4 -0
- data/tasks/git_flow_pivotal.rake +132 -0
- metadata +56 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Yak
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# GitFlowPivotal
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'git_flow_pivotal'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install git_flow_pivotal
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'git_flow_pivotal/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "git_flow_pivotal"
|
8
|
+
gem.version = GitFlowPivotal::VERSION
|
9
|
+
gem.authors = ["Yak"]
|
10
|
+
gem.email = ["yakov.rabinovich@gmail.com"]
|
11
|
+
gem.description = %q{This is a gem to help create a fast workflow with git-flow and pivotal tracker.%}
|
12
|
+
gem.summary = %q{How is a summary different from a description?}
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "pivotal-tracker"
|
3
|
+
namespace :pt do
|
4
|
+
def story_to_branch_name(story, length = 5)
|
5
|
+
return if story == nil
|
6
|
+
name = story.name
|
7
|
+
name.downcase!
|
8
|
+
# remove individual offending chars: single quote, double quote, open
|
9
|
+
# paren, close paren, colon, backslash, forwardslash and replace with
|
10
|
+
# an empty string (aka nothing)
|
11
|
+
name.gsub!(/['"\.\(\):\\\/]/,"")
|
12
|
+
# remove remaining cl.ly links
|
13
|
+
name.gsub!(/httpclly\S*/,"")
|
14
|
+
# remove dash and replace with space
|
15
|
+
name.gsub!(/-/," ")
|
16
|
+
# do the truncate here, after all the removal & before the _ injection
|
17
|
+
words = name.split()
|
18
|
+
#remove non critical words (experiment with this)
|
19
|
+
words = words - %w(feature scenario for in on a an the of so that they be able to are it its with)
|
20
|
+
name = words[0..(length-1)].join(' ')
|
21
|
+
|
22
|
+
# replace all instances of one or more spaces with _
|
23
|
+
name.gsub!(/\s+/,"_")
|
24
|
+
"#{name}_#{story.id}"
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_project
|
29
|
+
token = `git config --get pivotal.token`
|
30
|
+
projectid = `git config --get pivotal.projectid`
|
31
|
+
|
32
|
+
PivotalTracker::Client.token = token
|
33
|
+
PivotalTracker::Client.use_ssl = true
|
34
|
+
PivotalTracker::Project.find projectid
|
35
|
+
end
|
36
|
+
|
37
|
+
def get_username
|
38
|
+
`git config --get pivotal.fullname`
|
39
|
+
end
|
40
|
+
|
41
|
+
def current_branch
|
42
|
+
`git rev-parse --abbrev-ref HEAD`
|
43
|
+
end
|
44
|
+
|
45
|
+
def branch_type_and_name
|
46
|
+
current_branch.split('/')
|
47
|
+
end
|
48
|
+
|
49
|
+
def current_branch_story_id
|
50
|
+
current_branch.split('_').last.strip
|
51
|
+
end
|
52
|
+
|
53
|
+
desc "list available pivotal tracker tix assigned to me from which to create a git branch"
|
54
|
+
task :list do
|
55
|
+
project = get_project
|
56
|
+
username = get_username
|
57
|
+
conditions = { state: ["unstarted", "rejected"], owned_by: username }
|
58
|
+
stories = project.stories.all(conditions)
|
59
|
+
|
60
|
+
if stories.count > 0
|
61
|
+
puts "Select the story you'd like to start, or press 0 to cancel."
|
62
|
+
puts ""
|
63
|
+
story_hash = {}
|
64
|
+
stories.each_with_index do |story, index|
|
65
|
+
branch_name = story_to_branch_name story
|
66
|
+
story_hash[index + 1] = "#{branch_name}"
|
67
|
+
puts "#{index + 1}. #{branch_name}"
|
68
|
+
end
|
69
|
+
|
70
|
+
input = STDIN.gets.strip
|
71
|
+
story_num = input.split(",")[0].to_i
|
72
|
+
if story_hash.has_key?(story_num)
|
73
|
+
story_id = story_hash[story_num].split('_').last.strip
|
74
|
+
story = project.stories.find(story_id)
|
75
|
+
puts ""
|
76
|
+
puts "Your story has been marked started in tracker"
|
77
|
+
story.update({current_state: "started", other_id: 0})
|
78
|
+
|
79
|
+
output = `git flow feature start "#{story_hash[story_num]}"`
|
80
|
+
print output
|
81
|
+
else
|
82
|
+
exit
|
83
|
+
end
|
84
|
+
else
|
85
|
+
puts "There are no available stories right now!"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
desc "add a comment to the current story"
|
90
|
+
task :comment do
|
91
|
+
project = get_project
|
92
|
+
story = project.stories.find(current_branch_story_id)
|
93
|
+
unless story
|
94
|
+
puts ""
|
95
|
+
puts "No pivotal story matches this branch"
|
96
|
+
puts ""
|
97
|
+
exit
|
98
|
+
end
|
99
|
+
unless ENV['text']
|
100
|
+
puts ""
|
101
|
+
puts "No text provided."
|
102
|
+
puts "Usage: pt:comment text='My comment'"
|
103
|
+
puts ""
|
104
|
+
exit
|
105
|
+
end
|
106
|
+
|
107
|
+
story.notes.create(text: ENV['text'], noted_at: Time.now)
|
108
|
+
puts ""
|
109
|
+
puts "Your comment has been added."
|
110
|
+
puts ""
|
111
|
+
end
|
112
|
+
|
113
|
+
desc "finish current story"
|
114
|
+
task :finish do
|
115
|
+
project = get_project
|
116
|
+
story = project.stories.find(current_branch_story_id)
|
117
|
+
story.update({current_state: "finished", other_id: 0})
|
118
|
+
branch_type, branch_name = branch_type_and_name
|
119
|
+
puts ""
|
120
|
+
puts "Your story has been marked finished in tracker"
|
121
|
+
print `git flow #{branch_type} finish #{branch_name}`
|
122
|
+
end
|
123
|
+
|
124
|
+
desc "view current story online"
|
125
|
+
task :web do
|
126
|
+
project = get_project
|
127
|
+
story = project.stories.find(current_branch_story_id)
|
128
|
+
`open #{story.url}`
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
|
metadata
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: git_flow_pivotal
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Yak
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-11-10 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: This is a gem to help create a fast workflow with git-flow and pivotal
|
15
|
+
tracker.%
|
16
|
+
email:
|
17
|
+
- yakov.rabinovich@gmail.com
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- .gitignore
|
23
|
+
- Gemfile
|
24
|
+
- LICENSE.txt
|
25
|
+
- README.md
|
26
|
+
- Rakefile
|
27
|
+
- git_flow_pivotal.gemspec
|
28
|
+
- lib/git_flow_pivotal.rb
|
29
|
+
- lib/git_flow_pivotal/railtie.rb
|
30
|
+
- lib/git_flow_pivotal/version.rb
|
31
|
+
- tasks/git_flow_pivotal.rake
|
32
|
+
homepage: ''
|
33
|
+
licenses: []
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options: []
|
36
|
+
require_paths:
|
37
|
+
- lib
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ! '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
requirements: []
|
51
|
+
rubyforge_project:
|
52
|
+
rubygems_version: 1.8.24
|
53
|
+
signing_key:
|
54
|
+
specification_version: 3
|
55
|
+
summary: How is a summary different from a description?
|
56
|
+
test_files: []
|