git-pivot 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +50 -0
- data/Rakefile +2 -0
- data/bin/git-pivot +6 -0
- data/git-pivot.gemspec +23 -0
- data/lib/git-pivot.rb +6 -0
- data/lib/git-pivot/git.rb +73 -0
- data/lib/git-pivot/manager.rb +39 -0
- data/lib/git-pivot/pivotal.rb +68 -0
- data/lib/git-pivot/shared.rb +11 -0
- metadata +111 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2011 Luke van der Hoeven
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
GitPivot
|
2
|
+
========
|
3
|
+
|
4
|
+
Requirements
|
5
|
+
------------
|
6
|
+
|
7
|
+
* Git
|
8
|
+
* A Pivotal Tracker account
|
9
|
+
* Github account (not necessary, but if you're using PT, you probably already have it).
|
10
|
+
|
11
|
+
Install
|
12
|
+
-------
|
13
|
+
|
14
|
+
`gem install git-pivot`
|
15
|
+
|
16
|
+
TODO
|
17
|
+
----
|
18
|
+
|
19
|
+
Make. Moar. Awesome.
|
20
|
+
|
21
|
+
Also, it'd be cool to make tracker engines configurable. For example, maybe I
|
22
|
+
want to use GH Issues over PT, or maybe Lighthouse. Should be easy to make extendable
|
23
|
+
since the Tracker/Repo drivers are separated out.
|
24
|
+
|
25
|
+
Development
|
26
|
+
-----------
|
27
|
+
|
28
|
+
* Fork
|
29
|
+
* Get coffee
|
30
|
+
* Add code/fix bugs
|
31
|
+
* Please test
|
32
|
+
* Pull request with good a explaination of change.
|
33
|
+
* Celebrate!
|
34
|
+
|
35
|
+
Remarks
|
36
|
+
-------
|
37
|
+
|
38
|
+
Some people (mostly myself) are asking themselves if I'm ripping off the wonderful: [GitPivotal][1] gem. The answer is most definitely yes. I liked what
|
39
|
+
[Jeff Tucker][2] was trying to accomplish, my workflow was just different and a little more disorganized. My PT is not as orderly as the workflow his gem
|
40
|
+
tries to enforce (maybe it should be). But whatever the case, I am a fan of [GitPivotal][1] and I tried to show that by making a better version here using
|
41
|
+
some of the ideas found there. No hate :)
|
42
|
+
|
43
|
+
License
|
44
|
+
-------
|
45
|
+
|
46
|
+
MIT. See the LICENSE file.
|
47
|
+
|
48
|
+
[1]: https://github.com/trydionel/git-pivotal
|
49
|
+
[2]: https://github.com/trydionel
|
50
|
+
|
data/Rakefile
ADDED
data/bin/git-pivot
ADDED
data/git-pivot.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = "git-pivot"
|
5
|
+
s.version = "0.0.1"
|
6
|
+
s.platform = Gem::Platform::RUBY
|
7
|
+
s.authors = ["Luke van der Hoeven"]
|
8
|
+
s.email = ["hungerandthirst@gmail.com"]
|
9
|
+
s.homepage = "https://github.com/plukevdh/git-pivot"
|
10
|
+
s.summary = %q{GitPivot: Integrate your git and pivotal workflow.}
|
11
|
+
s.description = %q{GitPivot is a Git/Github/PivotalTracker integration toolset. It tries to lighten you workflow to a smaller set of commands.}
|
12
|
+
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
|
18
|
+
s.add_dependency "grit"
|
19
|
+
s.add_dependency "pivotal-tracker"
|
20
|
+
s.add_dependency "thor"
|
21
|
+
|
22
|
+
s.add_development_dependency "rspec"
|
23
|
+
end
|
data/lib/git-pivot.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'grit'
|
2
|
+
|
3
|
+
module GitPivot
|
4
|
+
module Git
|
5
|
+
extend GitPivot::Shared
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def start(branch_name)
|
9
|
+
create_branch(branch_name)
|
10
|
+
"Switched to branch #{branch_name}..."
|
11
|
+
end
|
12
|
+
|
13
|
+
def finish(commit)
|
14
|
+
if has_changes? && commit
|
15
|
+
out "Please enter your commit message: "
|
16
|
+
close_commit input
|
17
|
+
elsif has_changes?
|
18
|
+
exit out "Please commit changes before closing ticket.\n"
|
19
|
+
end
|
20
|
+
|
21
|
+
merge_branch
|
22
|
+
out "Merged changes back to master.\n"
|
23
|
+
end
|
24
|
+
|
25
|
+
def config(param)
|
26
|
+
repo.config[param]
|
27
|
+
end
|
28
|
+
|
29
|
+
def repo
|
30
|
+
@repo ||= Grit::Repo.new(`pwd`.strip)
|
31
|
+
end
|
32
|
+
|
33
|
+
def branch
|
34
|
+
@branch ||= repo.head.name
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
def info
|
39
|
+
"""
|
40
|
+
-- Git Info --
|
41
|
+
Branch name: #{branch}
|
42
|
+
"""
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
def create_branch(name)
|
47
|
+
`git branch #{name}`
|
48
|
+
`git checkout #{name}`
|
49
|
+
end
|
50
|
+
|
51
|
+
def integration_branch
|
52
|
+
branch = config "pivotal.integration-branch"
|
53
|
+
branch = 'master' unless branch
|
54
|
+
end
|
55
|
+
|
56
|
+
# TODO: error detect
|
57
|
+
def merge_branch
|
58
|
+
from = branch
|
59
|
+
`git checkout #{integration_branch}`
|
60
|
+
`git merge #{from}`
|
61
|
+
`git branch -d #{from}`
|
62
|
+
end
|
63
|
+
|
64
|
+
def close_commit(input)
|
65
|
+
repo.commit_all(input)
|
66
|
+
end
|
67
|
+
|
68
|
+
def has_changes?
|
69
|
+
!repo.status.changed.empty?
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# This class manage all input from the cli
|
2
|
+
# It passes off commands to their respective handlers
|
3
|
+
# letting you manage branches, tickets, from the cli
|
4
|
+
require 'thor'
|
5
|
+
|
6
|
+
module GitPivot
|
7
|
+
class Manager < Thor
|
8
|
+
include GitPivot::Shared
|
9
|
+
|
10
|
+
desc "info", "Gives you current PivotalTracker/Github information about the current ticket."
|
11
|
+
def info
|
12
|
+
out GitPivot::Git.info
|
13
|
+
out GitPivot::Pivotal.info
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "start TICKET_ID", "Start a story."
|
17
|
+
method_option :mine, type: :boolean, aliases: "-m", desc: "Will ignore ticket id and and simply grab the first in your queue"
|
18
|
+
def start(ticket=nil)
|
19
|
+
id, text = GitPivot::Pivotal.start(ticket, options[:mine])
|
20
|
+
|
21
|
+
out text
|
22
|
+
out "\n"
|
23
|
+
out GitPivot::Git.start(id)
|
24
|
+
out "\nYou are now licensed to develop. Godspeed.\n"
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
desc "finish", "Finish a story"
|
29
|
+
method_option :commit, type: :boolean, aliases: "-c",
|
30
|
+
desc: "Commit all existing changes with a message (and additional [Delivers: XXX] tag)."
|
31
|
+
def finish
|
32
|
+
GitPivot::Pivotal.finish
|
33
|
+
GitPivot::Git.finish(options[:commit])
|
34
|
+
out "Story complete.\n"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'pivotal-tracker'
|
2
|
+
|
3
|
+
# in order to configure your pivotal project, you'll need to set your Pivotal info
|
4
|
+
# as part of your gitconfig
|
5
|
+
#
|
6
|
+
# For your generic PT info, set the following option as part of your global opts:
|
7
|
+
# `git config --global pivotal.api-token XXX`
|
8
|
+
# `git config --global pivotal.full-nam FULL NAME`
|
9
|
+
#
|
10
|
+
# For your project, set your PT project id:
|
11
|
+
# `git config --local pivotal.project-id'
|
12
|
+
|
13
|
+
module GitPivot
|
14
|
+
module Pivotal
|
15
|
+
extend GitPivot::Shared
|
16
|
+
|
17
|
+
class << self
|
18
|
+
def project
|
19
|
+
tracker
|
20
|
+
@project ||= PivotalTracker::Project.find GitPivot::Git.config 'pivotal.project-id'
|
21
|
+
end
|
22
|
+
|
23
|
+
def user
|
24
|
+
@user ||= GitPivot::Git.config 'pivotal.full-name'
|
25
|
+
end
|
26
|
+
|
27
|
+
# will ignore id if mine is true
|
28
|
+
def start(id=nil, mine=false)
|
29
|
+
story = (mine || id.nil?) ? project.stories.all(owned_by: user).first : project.stories.find(id)
|
30
|
+
|
31
|
+
story.update(owned_by: user, current_state: :started)
|
32
|
+
return ["pt-#{story.story_type}-#{story.id}", "Story #{id} started..."]
|
33
|
+
end
|
34
|
+
|
35
|
+
def finish
|
36
|
+
current_story.update(current_state: :finished)
|
37
|
+
out "Marked story as finished.\n"
|
38
|
+
end
|
39
|
+
|
40
|
+
def info
|
41
|
+
current_story
|
42
|
+
return "No info found for Pivotal Tracker.\n" if @story.nil?
|
43
|
+
"""
|
44
|
+
-- Pivotal Info --
|
45
|
+
Name: #{@story.name}
|
46
|
+
URL: #{@story.url}
|
47
|
+
Desc: #{@story.description}
|
48
|
+
"""
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
def tracker
|
53
|
+
PivotalTracker::Client.token = GitPivot::Git.config 'pivotal.api-token'
|
54
|
+
PivotalTracker::Client.use_ssl = true if GitPivot::Git.config 'pivotal.use-ssl'
|
55
|
+
end
|
56
|
+
|
57
|
+
def current_story_id
|
58
|
+
@story_id ||= GitPivot::Git.branch.split('-').last.to_i
|
59
|
+
end
|
60
|
+
|
61
|
+
def current_story
|
62
|
+
return out "You are not currently working on a story branch.\n" if current_story_id == 0
|
63
|
+
@story ||= project.stories.find(current_story_id)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: git-pivot
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Luke van der Hoeven
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-05-12 00:00:00 -04:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: grit
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pivotal-tracker
|
29
|
+
prerelease: false
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: "0"
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: thor
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: "0"
|
47
|
+
type: :runtime
|
48
|
+
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: rspec
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
|
+
type: :development
|
59
|
+
version_requirements: *id004
|
60
|
+
description: GitPivot is a Git/Github/PivotalTracker integration toolset. It tries to lighten you workflow to a smaller set of commands.
|
61
|
+
email:
|
62
|
+
- hungerandthirst@gmail.com
|
63
|
+
executables:
|
64
|
+
- git-pivot
|
65
|
+
extensions: []
|
66
|
+
|
67
|
+
extra_rdoc_files: []
|
68
|
+
|
69
|
+
files:
|
70
|
+
- .gitignore
|
71
|
+
- Gemfile
|
72
|
+
- LICENSE
|
73
|
+
- README.md
|
74
|
+
- Rakefile
|
75
|
+
- bin/git-pivot
|
76
|
+
- git-pivot.gemspec
|
77
|
+
- lib/git-pivot.rb
|
78
|
+
- lib/git-pivot/git.rb
|
79
|
+
- lib/git-pivot/manager.rb
|
80
|
+
- lib/git-pivot/pivotal.rb
|
81
|
+
- lib/git-pivot/shared.rb
|
82
|
+
has_rdoc: true
|
83
|
+
homepage: https://github.com/plukevdh/git-pivot
|
84
|
+
licenses: []
|
85
|
+
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options: []
|
88
|
+
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
none: false
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: "0"
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: "0"
|
103
|
+
requirements: []
|
104
|
+
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 1.6.2
|
107
|
+
signing_key:
|
108
|
+
specification_version: 3
|
109
|
+
summary: "GitPivot: Integrate your git and pivotal workflow."
|
110
|
+
test_files: []
|
111
|
+
|