git-pivotal-tracker 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/.rspec +2 -0
- data/.rvmrc +1 -0
- data/.travis.yml +3 -0
- data/CHANGELOG +45 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +74 -0
- data/LICENSE +21 -0
- data/Rakefile +24 -0
- data/VERSION +1 -0
- data/bin/git-accept +7 -0
- data/bin/git-block +7 -0
- data/bin/git-finish +7 -0
- data/bin/git-info +7 -0
- data/bin/git-start +8 -0
- data/bin/git-unblock +7 -0
- data/features/accept.feature +140 -0
- data/features/block.feature +94 -0
- data/features/finish.feature +119 -0
- data/features/info.feature +99 -0
- data/features/start.feature +113 -0
- data/features/step_definitions/steps.rb +114 -0
- data/features/support/dsl/assertions.rb +11 -0
- data/features/support/dsl/data.rb +11 -0
- data/features/support/dsl/pivotal.rb +76 -0
- data/features/support/env.rb +6 -0
- data/features/support/git-pivotal.rb +69 -0
- data/features/test_repo/origin.git/COMMIT_EDITMSG +1 -0
- data/features/test_repo/origin.git/HEAD +1 -0
- data/features/test_repo/origin.git/config +8 -0
- data/features/test_repo/origin.git/description +1 -0
- data/features/test_repo/origin.git/hooks/applypatch-msg.sample +15 -0
- data/features/test_repo/origin.git/hooks/commit-msg.sample +24 -0
- data/features/test_repo/origin.git/hooks/post-commit.sample +8 -0
- data/features/test_repo/origin.git/hooks/post-receive.sample +15 -0
- data/features/test_repo/origin.git/hooks/post-update.sample +8 -0
- data/features/test_repo/origin.git/hooks/pre-applypatch.sample +14 -0
- data/features/test_repo/origin.git/hooks/pre-commit.sample +46 -0
- data/features/test_repo/origin.git/hooks/pre-rebase.sample +169 -0
- data/features/test_repo/origin.git/hooks/prepare-commit-msg.sample +36 -0
- data/features/test_repo/origin.git/hooks/update.sample +128 -0
- data/features/test_repo/origin.git/index +0 -0
- data/features/test_repo/origin.git/info/exclude +6 -0
- data/features/test_repo/origin.git/logs/HEAD +1 -0
- data/features/test_repo/origin.git/logs/refs/heads/master +1 -0
- data/features/test_repo/origin.git/objects/0c/6f7b1384910d1a2f137590095f008a06c7e00c +0 -0
- data/features/test_repo/origin.git/objects/10/ecf2b7ce989f01f3f7266e712b48d9275f2635 +0 -0
- data/features/test_repo/origin.git/objects/a5/71d56305df09fb060f6ccb730b46080d305beb +0 -0
- data/features/test_repo/origin.git/refs/heads/master +1 -0
- data/features/test_repo/readme +1 -0
- data/features/unblock.feature +68 -0
- data/git-pivotal-tracker.gemspec +27 -0
- data/lib/commands/accept.rb +76 -0
- data/lib/commands/base.rb +128 -0
- data/lib/commands/block.rb +59 -0
- data/lib/commands/bug.rb +19 -0
- data/lib/commands/card.rb +32 -0
- data/lib/commands/chore.rb +19 -0
- data/lib/commands/feature.rb +19 -0
- data/lib/commands/finish.rb +59 -0
- data/lib/commands/info.rb +58 -0
- data/lib/commands/map.rb +10 -0
- data/lib/commands/pick.rb +76 -0
- data/lib/commands/start.rb +35 -0
- data/lib/commands/unblock.rb +55 -0
- data/lib/git-pivotal-tracker.rb +11 -0
- data/readme.markdown +95 -0
- data/spec/commands/base_spec.rb +151 -0
- data/spec/commands/bug_spec.rb +24 -0
- data/spec/commands/chore_spec.rb +24 -0
- data/spec/commands/feature_spec.rb +24 -0
- data/spec/commands/finish_spec.rb +125 -0
- data/spec/commands/map_spec.rb +14 -0
- data/spec/commands/start_spec.rb +29 -0
- data/spec/factories.rb +13 -0
- data/spec/factory.rb +26 -0
- data/spec/spec_helper.rb +24 -0
- metadata +251 -0
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
#
|
3
|
+
# An example hook script to prepare the commit log message.
|
4
|
+
# Called by "git commit" with the name of the file that has the
|
5
|
+
# commit message, followed by the description of the commit
|
6
|
+
# message's source. The hook's purpose is to edit the commit
|
7
|
+
# message file. If the hook fails with a non-zero status,
|
8
|
+
# the commit is aborted.
|
9
|
+
#
|
10
|
+
# To enable this hook, rename this file to "prepare-commit-msg".
|
11
|
+
|
12
|
+
# This hook includes three examples. The first comments out the
|
13
|
+
# "Conflicts:" part of a merge commit.
|
14
|
+
#
|
15
|
+
# The second includes the output of "git diff --name-status -r"
|
16
|
+
# into the message, just before the "git status" output. It is
|
17
|
+
# commented because it doesn't cope with --amend or with squashed
|
18
|
+
# commits.
|
19
|
+
#
|
20
|
+
# The third example adds a Signed-off-by line to the message, that can
|
21
|
+
# still be edited. This is rarely a good idea.
|
22
|
+
|
23
|
+
case "$2,$3" in
|
24
|
+
merge,)
|
25
|
+
/usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;;
|
26
|
+
|
27
|
+
# ,|template,)
|
28
|
+
# /usr/bin/perl -i.bak -pe '
|
29
|
+
# print "\n" . `git diff --cached --name-status -r`
|
30
|
+
# if /^#/ && $first++ == 0' "$1" ;;
|
31
|
+
|
32
|
+
*) ;;
|
33
|
+
esac
|
34
|
+
|
35
|
+
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
|
36
|
+
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
|
@@ -0,0 +1,128 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
#
|
3
|
+
# An example hook script to blocks unannotated tags from entering.
|
4
|
+
# Called by "git receive-pack" with arguments: refname sha1-old sha1-new
|
5
|
+
#
|
6
|
+
# To enable this hook, rename this file to "update".
|
7
|
+
#
|
8
|
+
# Config
|
9
|
+
# ------
|
10
|
+
# hooks.allowunannotated
|
11
|
+
# This boolean sets whether unannotated tags will be allowed into the
|
12
|
+
# repository. By default they won't be.
|
13
|
+
# hooks.allowdeletetag
|
14
|
+
# This boolean sets whether deleting tags will be allowed in the
|
15
|
+
# repository. By default they won't be.
|
16
|
+
# hooks.allowmodifytag
|
17
|
+
# This boolean sets whether a tag may be modified after creation. By default
|
18
|
+
# it won't be.
|
19
|
+
# hooks.allowdeletebranch
|
20
|
+
# This boolean sets whether deleting branches will be allowed in the
|
21
|
+
# repository. By default they won't be.
|
22
|
+
# hooks.denycreatebranch
|
23
|
+
# This boolean sets whether remotely creating branches will be denied
|
24
|
+
# in the repository. By default this is allowed.
|
25
|
+
#
|
26
|
+
|
27
|
+
# --- Command line
|
28
|
+
refname="$1"
|
29
|
+
oldrev="$2"
|
30
|
+
newrev="$3"
|
31
|
+
|
32
|
+
# --- Safety check
|
33
|
+
if [ -z "$GIT_DIR" ]; then
|
34
|
+
echo "Don't run this script from the command line." >&2
|
35
|
+
echo " (if you want, you could supply GIT_DIR then run" >&2
|
36
|
+
echo " $0 <ref> <oldrev> <newrev>)" >&2
|
37
|
+
exit 1
|
38
|
+
fi
|
39
|
+
|
40
|
+
if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
|
41
|
+
echo "Usage: $0 <ref> <oldrev> <newrev>" >&2
|
42
|
+
exit 1
|
43
|
+
fi
|
44
|
+
|
45
|
+
# --- Config
|
46
|
+
allowunannotated=$(git config --bool hooks.allowunannotated)
|
47
|
+
allowdeletebranch=$(git config --bool hooks.allowdeletebranch)
|
48
|
+
denycreatebranch=$(git config --bool hooks.denycreatebranch)
|
49
|
+
allowdeletetag=$(git config --bool hooks.allowdeletetag)
|
50
|
+
allowmodifytag=$(git config --bool hooks.allowmodifytag)
|
51
|
+
|
52
|
+
# check for no description
|
53
|
+
projectdesc=$(sed -e '1q' "$GIT_DIR/description")
|
54
|
+
case "$projectdesc" in
|
55
|
+
"Unnamed repository"* | "")
|
56
|
+
echo "*** Project description file hasn't been set" >&2
|
57
|
+
exit 1
|
58
|
+
;;
|
59
|
+
esac
|
60
|
+
|
61
|
+
# --- Check types
|
62
|
+
# if $newrev is 0000...0000, it's a commit to delete a ref.
|
63
|
+
zero="0000000000000000000000000000000000000000"
|
64
|
+
if [ "$newrev" = "$zero" ]; then
|
65
|
+
newrev_type=delete
|
66
|
+
else
|
67
|
+
newrev_type=$(git cat-file -t $newrev)
|
68
|
+
fi
|
69
|
+
|
70
|
+
case "$refname","$newrev_type" in
|
71
|
+
refs/tags/*,commit)
|
72
|
+
# un-annotated tag
|
73
|
+
short_refname=${refname##refs/tags/}
|
74
|
+
if [ "$allowunannotated" != "true" ]; then
|
75
|
+
echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2
|
76
|
+
echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2
|
77
|
+
exit 1
|
78
|
+
fi
|
79
|
+
;;
|
80
|
+
refs/tags/*,delete)
|
81
|
+
# delete tag
|
82
|
+
if [ "$allowdeletetag" != "true" ]; then
|
83
|
+
echo "*** Deleting a tag is not allowed in this repository" >&2
|
84
|
+
exit 1
|
85
|
+
fi
|
86
|
+
;;
|
87
|
+
refs/tags/*,tag)
|
88
|
+
# annotated tag
|
89
|
+
if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1
|
90
|
+
then
|
91
|
+
echo "*** Tag '$refname' already exists." >&2
|
92
|
+
echo "*** Modifying a tag is not allowed in this repository." >&2
|
93
|
+
exit 1
|
94
|
+
fi
|
95
|
+
;;
|
96
|
+
refs/heads/*,commit)
|
97
|
+
# branch
|
98
|
+
if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then
|
99
|
+
echo "*** Creating a branch is not allowed in this repository" >&2
|
100
|
+
exit 1
|
101
|
+
fi
|
102
|
+
;;
|
103
|
+
refs/heads/*,delete)
|
104
|
+
# delete branch
|
105
|
+
if [ "$allowdeletebranch" != "true" ]; then
|
106
|
+
echo "*** Deleting a branch is not allowed in this repository" >&2
|
107
|
+
exit 1
|
108
|
+
fi
|
109
|
+
;;
|
110
|
+
refs/remotes/*,commit)
|
111
|
+
# tracking branch
|
112
|
+
;;
|
113
|
+
refs/remotes/*,delete)
|
114
|
+
# delete tracking branch
|
115
|
+
if [ "$allowdeletebranch" != "true" ]; then
|
116
|
+
echo "*** Deleting a tracking branch is not allowed in this repository" >&2
|
117
|
+
exit 1
|
118
|
+
fi
|
119
|
+
;;
|
120
|
+
*)
|
121
|
+
# Anything else (is there anything else?)
|
122
|
+
echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2
|
123
|
+
exit 1
|
124
|
+
;;
|
125
|
+
esac
|
126
|
+
|
127
|
+
# --- Finished
|
128
|
+
exit 0
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
0000000000000000000000000000000000000000 10ecf2b7ce989f01f3f7266e712b48d9275f2635 Jeff Tucker <trydionel@gmail.com> 1279979728 -0400 commit (initial): A blank repo for testing
|
@@ -0,0 +1 @@
|
|
1
|
+
0000000000000000000000000000000000000000 10ecf2b7ce989f01f3f7266e712b48d9275f2635 Jeff Tucker <trydionel@gmail.com> 1279979728 -0400 commit (initial): A blank repo for testing
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
10ecf2b7ce989f01f3f7266e712b48d9275f2635
|
@@ -0,0 +1 @@
|
|
1
|
+
Testing repo
|
@@ -0,0 +1,68 @@
|
|
1
|
+
Feature: git block
|
2
|
+
|
3
|
+
In order to get information about a specific card you can issue one of the following
|
4
|
+
commands:
|
5
|
+
|
6
|
+
git unblock
|
7
|
+
git unblock <options>
|
8
|
+
git unblock <card_id>
|
9
|
+
git unblock <card_id> <options>
|
10
|
+
|
11
|
+
Supported options:
|
12
|
+
-k <api_key> - specify the Pivotal API key to use. Overrides configuration.
|
13
|
+
-p <project_id> - specify the Pivotal project id to use. Overrides configuration.
|
14
|
+
|
15
|
+
Background:
|
16
|
+
Given I have a Pivotal Tracker feature named "Test Story" with description "This is the description!"
|
17
|
+
And I am on the "CURRENT_CARD-feature" branch
|
18
|
+
|
19
|
+
# This scenario is to test the presence of a bug in Pivotal Tracker's v3 API. It is
|
20
|
+
# impossible to remove the last label from a story. When this fails then git-unblock
|
21
|
+
# will need to be updated to not use a placeholder label.
|
22
|
+
Scenario: Is Pivotal's API for removing the last label on a card still broken?
|
23
|
+
Given I have configured the Git repos for Pivotal
|
24
|
+
And the card is labeled "blocked"
|
25
|
+
When I run `git-unblock`
|
26
|
+
Then the card CURRENT_CARD should have the "blocked" label
|
27
|
+
|
28
|
+
Scenario: Executing with no settings
|
29
|
+
When I run `git-unblock`
|
30
|
+
Then the output should contain:
|
31
|
+
"""
|
32
|
+
Pivotal Tracker API Token and Project ID are required
|
33
|
+
"""
|
34
|
+
And the exit status should be 1
|
35
|
+
|
36
|
+
Scenario: Unblocking the current topic branch
|
37
|
+
Given I have configured the Git repos for Pivotal
|
38
|
+
And the card is labeled "blocked"
|
39
|
+
When I run `git-unblock`
|
40
|
+
Then the output should contain "Story CURRENT_CARD has been unblocked."
|
41
|
+
When the current card is refreshed
|
42
|
+
Then the card CURRENT_CARD should not have the "blocked" label
|
43
|
+
|
44
|
+
Scenario: Unlocking a specific card
|
45
|
+
Given I have configured the Git repos for Pivotal
|
46
|
+
And the card is labeled "blocked"
|
47
|
+
When I run `git-unblock CURRENT_CARD`
|
48
|
+
Then the output should contain "Story CURRENT_CARD has been unblocked."
|
49
|
+
When the current card is refreshed
|
50
|
+
Then the card CURRENT_CARD should not have the "blocked" label
|
51
|
+
|
52
|
+
Scenario: Unblocking a card that is not blocked
|
53
|
+
Given I have configured the Git repos for Pivotal
|
54
|
+
When I run `git-unblock CURRENT_CARD`
|
55
|
+
Then the output should contain "Story CURRENT_CARD is already unblocked."
|
56
|
+
When the current card is refreshed
|
57
|
+
Then the card CURRENT_CARD should not have the "blocked" label
|
58
|
+
|
59
|
+
Scenario: Trying to unblock when not on a topic branch and not supplying a card id
|
60
|
+
Given I have configured the Git repos for Pivotal
|
61
|
+
And I am on the "foo" branch
|
62
|
+
Then I should be on the "foo" branch
|
63
|
+
When I run `git-unblock`
|
64
|
+
Then the output should contain:
|
65
|
+
"""
|
66
|
+
No story id was supplied and you aren't on a topic branch!
|
67
|
+
"""
|
68
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "git-pivotal-tracker"
|
6
|
+
s.version = IO.read("VERSION")
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ["Zach Dennis", "Jeff Tucker", "Sam Stokes"]
|
9
|
+
s.email = "zach.dennis@gmail.com"
|
10
|
+
s.homepage = "https://github.com/zdennis/git-pivotal"
|
11
|
+
s.summary = "A collection of git utilities to ease integration with Pivotal Tracker."
|
12
|
+
s.description = "A collection of git utilities to ease integration with Pivotal Tracker."
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
|
19
|
+
s.add_runtime_dependency(%q<pivotal-tracker>, [">= 0"])
|
20
|
+
s.add_development_dependency(%q<rake>, [">= 0"])
|
21
|
+
s.add_development_dependency(%q<mocha>, [">= 0"])
|
22
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
23
|
+
s.add_development_dependency(%q<aruba>, [">= 0"])
|
24
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
25
|
+
s.add_development_dependency(%q<cucumber>, [">= 0"])
|
26
|
+
end
|
27
|
+
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'commands/base'
|
2
|
+
|
3
|
+
module Commands
|
4
|
+
class Accept < Base
|
5
|
+
def run!
|
6
|
+
super
|
7
|
+
|
8
|
+
unless story_id
|
9
|
+
put "Branch name must contain a Pivotal Tracker story id"
|
10
|
+
return 1
|
11
|
+
end
|
12
|
+
|
13
|
+
if story_is_acceptable?
|
14
|
+
accept_story!
|
15
|
+
return 0
|
16
|
+
else
|
17
|
+
put "Story is not in an acceptable state. It's currently #{story.current_state}."
|
18
|
+
return 1
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
protected
|
23
|
+
|
24
|
+
def accept_story!
|
25
|
+
put "Marking Story #{story_id} as accepted..."
|
26
|
+
if story.update(:current_state => "accepted")
|
27
|
+
topic_branch = current_branch
|
28
|
+
|
29
|
+
put "Pushing #{topic_branch} to #{remote}"
|
30
|
+
sys "git push --set-upstream #{remote} #{topic_branch}"
|
31
|
+
|
32
|
+
put "Pulling #{integration_branch}..."
|
33
|
+
sys "git checkout #{integration_branch}"
|
34
|
+
sys "git pull"
|
35
|
+
|
36
|
+
put "Merging #{topic_branch} into #{integration_branch}"
|
37
|
+
sys "git merge --no-ff #{topic_branch}"
|
38
|
+
|
39
|
+
put "Pushing #{integration_branch} to #{remote}"
|
40
|
+
sys "git push"
|
41
|
+
|
42
|
+
put "Now on #{integration_branch}."
|
43
|
+
|
44
|
+
return 0
|
45
|
+
else
|
46
|
+
put "Unable to mark Story #{story_id} as finished"
|
47
|
+
|
48
|
+
return 1
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def chore_and_acceptable?
|
53
|
+
story.story_type == "chore" && story.current_state == "accepted"
|
54
|
+
end
|
55
|
+
|
56
|
+
def bug_and_acceptable?
|
57
|
+
story.story_type == "bug" && %(finished delivered).include?(story.current_state)
|
58
|
+
end
|
59
|
+
|
60
|
+
def feature_and_acceptable?
|
61
|
+
story.story_type == "feature" && %(finished delivered).include?(story.current_state)
|
62
|
+
end
|
63
|
+
|
64
|
+
def story_is_acceptable?
|
65
|
+
chore_and_acceptable? || bug_and_acceptable? || feature_and_acceptable?
|
66
|
+
end
|
67
|
+
|
68
|
+
def story_id
|
69
|
+
match = current_branch[/\d+/] and match.to_i
|
70
|
+
end
|
71
|
+
|
72
|
+
def story
|
73
|
+
@story ||= project.stories.find(story_id)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'pivotal-tracker'
|
3
|
+
require 'optparse'
|
4
|
+
|
5
|
+
module Commands
|
6
|
+
class Base
|
7
|
+
|
8
|
+
attr_accessor :input, :output, :options
|
9
|
+
|
10
|
+
def initialize(*args)
|
11
|
+
@input = STDIN
|
12
|
+
@output = STDOUT
|
13
|
+
|
14
|
+
@options = {}
|
15
|
+
|
16
|
+
parse_gitconfig
|
17
|
+
parse_argv(*args)
|
18
|
+
end
|
19
|
+
|
20
|
+
def with(input, output)
|
21
|
+
tap do
|
22
|
+
@input = input
|
23
|
+
@output = output
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def put(string, newline=true)
|
28
|
+
@output.print(newline ? string + "\n" : string) unless options[:quiet]
|
29
|
+
end
|
30
|
+
|
31
|
+
def sys(cmd)
|
32
|
+
put cmd if options[:verbose]
|
33
|
+
system cmd #"#{cmd} > /dev/null 2>&1"
|
34
|
+
end
|
35
|
+
|
36
|
+
def get(cmd)
|
37
|
+
put cmd if options[:verbose]
|
38
|
+
`#{cmd}`
|
39
|
+
end
|
40
|
+
|
41
|
+
def run!
|
42
|
+
unless options[:api_token] && options[:project_id]
|
43
|
+
put "Pivotal Tracker API Token and Project ID are required"
|
44
|
+
return 1
|
45
|
+
end
|
46
|
+
|
47
|
+
PivotalTracker::Client.token = options[:api_token]
|
48
|
+
PivotalTracker::Client.use_ssl = options[:use_ssl]
|
49
|
+
|
50
|
+
return 0
|
51
|
+
end
|
52
|
+
|
53
|
+
protected
|
54
|
+
|
55
|
+
def on_parse(opts)
|
56
|
+
# no-op, override in sub-class to provide command specific options
|
57
|
+
end
|
58
|
+
|
59
|
+
def current_branch
|
60
|
+
@current_branch ||= get('git symbolic-ref HEAD').chomp.split('/').last
|
61
|
+
end
|
62
|
+
|
63
|
+
def project
|
64
|
+
@project ||= PivotalTracker::Project.find(options[:project_id])
|
65
|
+
end
|
66
|
+
|
67
|
+
def acceptance_branch
|
68
|
+
options[:acceptance_branch] || "acceptance"
|
69
|
+
end
|
70
|
+
|
71
|
+
def integration_branch
|
72
|
+
options[:integration_branch] || "master"
|
73
|
+
end
|
74
|
+
|
75
|
+
def full_name
|
76
|
+
options[:full_name]
|
77
|
+
end
|
78
|
+
|
79
|
+
def remote
|
80
|
+
options[:remote] || "origin"
|
81
|
+
end
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
def parse_gitconfig
|
86
|
+
token = get("git config --get pivotal.api-token").strip
|
87
|
+
name = get("git config --get pivotal.full-name").strip
|
88
|
+
id = get("git config --get pivotal.project-id").strip
|
89
|
+
remote = get("git config --get pivotal.remote").strip
|
90
|
+
acceptance_branch = get("git config --get pivotal.acceptance-branch").strip
|
91
|
+
integration_branch = get("git config --get pivotal.integration-branch").strip
|
92
|
+
only_mine = get("git config --get pivotal.only-mine").strip
|
93
|
+
append_name = get("git config --get pivotal.append-name").strip
|
94
|
+
use_ssl = get("git config --get pivotal.use-ssl").strip
|
95
|
+
|
96
|
+
options[:api_token] = token unless token == ""
|
97
|
+
options[:project_id] = id unless id == ""
|
98
|
+
options[:full_name] = name unless name == ""
|
99
|
+
options[:remote] = remote unless remote == ""
|
100
|
+
options[:acceptance_branch] = acceptance_branch unless acceptance_branch == ""
|
101
|
+
options[:integration_branch] = integration_branch unless integration_branch == ""
|
102
|
+
options[:only_mine] = (only_mine != "") unless name == ""
|
103
|
+
options[:append_name] = (append_name != "")
|
104
|
+
options[:use_ssl] = (/^true$/i.match(use_ssl))
|
105
|
+
end
|
106
|
+
|
107
|
+
def parse_argv(*args)
|
108
|
+
OptionParser.new do |opts|
|
109
|
+
opts.banner = "Usage: git pick [options]"
|
110
|
+
opts.on("-k", "--api-key=", "Pivotal Tracker API key") { |k| options[:api_token] = k }
|
111
|
+
opts.on("-p", "--project-id=", "Pivotal Tracker project id") { |p| options[:project_id] = p }
|
112
|
+
opts.on("-n", "--full-name=", "Pivotal Tracker full name") { |n| options[:full_name] = n }
|
113
|
+
opts.on("-b", "--integration-branch=", "The branch to merge finished stories back down onto") { |b| options[:integration_branch] = b }
|
114
|
+
opts.on("-m", "--only-mine", "Only select Pivotal Tracker stories assigned to you") { |m| options[:only_mine] = m }
|
115
|
+
opts.on("-S", "--use-ssl", "Use SSL for connection to Pivotal Tracker (for private repos(?))") { |s| options[:use_ssl] = s }
|
116
|
+
opts.on("-a", "--append-name", "whether to append the story id to branch name instead of prepend") { |a| options[:append_name] = a }
|
117
|
+
opts.on("-D", "--defaults", "Accept default options. No-interaction mode") { |d| options[:defaults] = d }
|
118
|
+
opts.on("-q", "--quiet", "Quiet, no-interaction mode") { |q| options[:quiet] = q }
|
119
|
+
opts.on("-v", "--[no-]verbose", "Run verbosely") { |v| options[:verbose] = v }
|
120
|
+
|
121
|
+
on_parse(opts)
|
122
|
+
|
123
|
+
opts.on_tail("-h", "--help", "This usage guide") { put opts.to_s; exit 0 }
|
124
|
+
end.parse!(args)
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
end
|