git_er_done 0.1.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.rvmrc +1 -1
- data/Gemfile +8 -0
- data/README.md +8 -0
- data/Rakefile +8 -0
- data/features/cli.feature +30 -0
- data/features/step_definitions/cli_steps.rb +15 -0
- data/features/support.rb/env.rb +5 -0
- data/git_er_done.gemspec +1 -1
- data/lib/git_er_done/actions.rb +21 -0
- data/lib/git_er_done/app.rb +38 -6
- data/lib/git_er_done/version.rb +1 -1
- metadata +15 -19
data/.gitignore
CHANGED
data/.rvmrc
CHANGED
@@ -1 +1 @@
|
|
1
|
-
rvm use 1.9.2
|
1
|
+
rvm use 1.9.2@rails3.0
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -9,6 +9,14 @@ This project exists for a few reasons:
|
|
9
9
|
3. Gives an interesting test case for my Thor talk at DCRUG and Arlington RUG.
|
10
10
|
4. Make doing the 'right' thing easy (i.e. feature branches should be simple. Smaller projects)
|
11
11
|
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
```
|
15
|
+
gem install git_er_done
|
16
|
+
```
|
17
|
+
|
18
|
+
This makes the `gd` command available on your system.
|
19
|
+
|
12
20
|
## Syntax
|
13
21
|
|
14
22
|
Things you can do:
|
data/Rakefile
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
Feature: CLI
|
2
|
+
|
3
|
+
In order to make doing the right thing easier in Git
|
4
|
+
As a programmer with a bad memory
|
5
|
+
I should be able to use a commandline tool to simplify my interface.
|
6
|
+
|
7
|
+
Scenario: Show the Version of the Gem
|
8
|
+
When I run `gd version`
|
9
|
+
Then the output should contain "Git-Er-Done"
|
10
|
+
And should display the current version
|
11
|
+
|
12
|
+
Scenario: Show version using -v
|
13
|
+
When I run `gd -v`
|
14
|
+
Then the output should contain "Git-Er-Done"
|
15
|
+
And should display the current version
|
16
|
+
|
17
|
+
Scenario: Start a New Feature
|
18
|
+
Given I am working on a git project
|
19
|
+
When I run `gd feature new_widget`
|
20
|
+
Then the output should contain "Switched to a new branch 'features/new_widget'"
|
21
|
+
|
22
|
+
Scenario: Sync a Branch
|
23
|
+
Given I am working on a git project
|
24
|
+
And I am working on the "features/new_widget" branch
|
25
|
+
When I run `gd sync`
|
26
|
+
Then the output should contain "Switched to branch 'master'"
|
27
|
+
And the output should contain "Switched to branch 'features/new_widget"
|
28
|
+
And the output should contain "Current branch features/new_widget is up to date"
|
29
|
+
|
30
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Given /^I am working on a git project$/ do
|
2
|
+
steps %Q{
|
3
|
+
Given I run `git init .`
|
4
|
+
And an empty file named "README"
|
5
|
+
And I run `git add README`
|
6
|
+
And I run `git commit -m 'First commit'`
|
7
|
+
}
|
8
|
+
end
|
9
|
+
|
10
|
+
Given /^I am working on the "(.*)" branch$/ do |branch|
|
11
|
+
steps "Given I run `git checkout -b #{branch}`"
|
12
|
+
end
|
13
|
+
When /^should display the current version$/ do
|
14
|
+
assert_partial_output(Git::Er::Done::VERSION, all_output)
|
15
|
+
end
|
data/git_er_done.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
|
-
[['thor', '~> 0.14.6'], ['
|
21
|
+
[['thor', '~> 0.14.6'], ['grit', '~>2.4']].each do |gem, version|
|
22
22
|
s.add_dependency(gem, version)
|
23
23
|
end
|
24
24
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Git
|
2
|
+
module Er
|
3
|
+
module Done
|
4
|
+
module Actions
|
5
|
+
|
6
|
+
# Run a git command.
|
7
|
+
# This is basically a straight copy/paste from http://api.rubyonrails.org/classes/Rails/Generators/Actions.html#method-i-git
|
8
|
+
# Avoids dragging in the entire rails stack for this one command.
|
9
|
+
def git(command={})
|
10
|
+
if command.is_a?(Symbol)
|
11
|
+
run "git #{command}"
|
12
|
+
else
|
13
|
+
command.each do |cmd, options|
|
14
|
+
run "git #{cmd} #{options}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/git_er_done/app.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'thor'
|
2
|
-
require 'rails/generators/actions'
|
3
2
|
require 'grit'
|
3
|
+
require 'git_er_done/actions'
|
4
4
|
|
5
5
|
module Git
|
6
6
|
module Er
|
@@ -8,7 +8,7 @@ module Git
|
|
8
8
|
class App < Thor
|
9
9
|
|
10
10
|
include Thor::Actions
|
11
|
-
include
|
11
|
+
include Git::Er::Done::Actions
|
12
12
|
|
13
13
|
FEATURES_PATH = "features/"
|
14
14
|
|
@@ -36,25 +36,46 @@ module Git
|
|
36
36
|
|
37
37
|
desc 'squash', 'Squash all commits from the current branch into a single commit.'
|
38
38
|
def squash
|
39
|
+
new_commits = commits_in_feature_branch.size
|
40
|
+
if new_commits < 2
|
41
|
+
puts "Only '#{new_commits}' new commits in this branch, so no squashing necessary."
|
42
|
+
return
|
43
|
+
end
|
39
44
|
# Squash all changes since we branched away from master
|
40
45
|
git :rebase => "-i master"
|
41
46
|
end
|
42
47
|
|
48
|
+
desc 'info', "Report information about the current feature branch you are in."
|
49
|
+
def info
|
50
|
+
commits = commits_in_feature_branch
|
51
|
+
puts "There are #{commits.size} new commits for #{current_branch_name}"
|
52
|
+
end
|
53
|
+
|
43
54
|
desc 'sync', 'Update your branch with the latest from master.'
|
44
55
|
def sync
|
45
|
-
return_to_branch =
|
56
|
+
return_to_branch = current_branch_name
|
46
57
|
git :checkout => :master
|
47
58
|
git :pull
|
48
59
|
git :checkout => return_to_branch
|
49
60
|
git :rebase => :master
|
50
61
|
end
|
51
|
-
|
62
|
+
|
63
|
+
desc 'version', 'Show the Git-Er-Done version and quit. (gd -v works too)'
|
64
|
+
map "-v" => :version
|
65
|
+
def version
|
66
|
+
puts "Git-Er-Done #{Git::Er::Done::VERSION}"
|
67
|
+
end
|
52
68
|
private
|
53
69
|
|
70
|
+
# Returns a list of all commits for the current branch since it was forked from master.
|
71
|
+
def commits_in_feature_branch
|
72
|
+
repo.commits_between(master_branch.name, current_branch.name)
|
73
|
+
end
|
74
|
+
|
54
75
|
# Returns the name of the feature for the current branch
|
55
76
|
# @return [String] Name of feature (not include features/)
|
56
77
|
def current_feature
|
57
|
-
b =
|
78
|
+
b = current_branch_name
|
58
79
|
if b.start_with?(FEATURES_PATH)
|
59
80
|
return b[FEATURES_PATH.length, b.length]
|
60
81
|
end
|
@@ -62,13 +83,24 @@ module Git
|
|
62
83
|
end
|
63
84
|
|
64
85
|
def current_branch
|
65
|
-
repo.head
|
86
|
+
repo.head
|
87
|
+
end
|
88
|
+
|
89
|
+
def current_branch_name
|
90
|
+
current_branch.name
|
66
91
|
end
|
67
92
|
|
68
93
|
def repo
|
69
94
|
repo ||= Grit::Repo.new('.')
|
70
95
|
end
|
71
96
|
|
97
|
+
def master_branch
|
98
|
+
repo.heads.each do |head|
|
99
|
+
return head if head.name == "master"
|
100
|
+
end
|
101
|
+
raise "No branch named 'master' found."
|
102
|
+
end
|
103
|
+
|
72
104
|
def feature_branch(name)
|
73
105
|
"#{FEATURES_PATH}#{name}"
|
74
106
|
end
|
data/lib/git_er_done/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git_er_done
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-01-13 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
16
|
-
requirement: &
|
16
|
+
requirement: &70179246615980 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,21 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.14.6
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: rails
|
27
|
-
requirement: &2153490500 !ruby/object:Gem::Requirement
|
28
|
-
none: false
|
29
|
-
requirements:
|
30
|
-
- - ~>
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 3.0.9
|
33
|
-
type: :runtime
|
34
|
-
prerelease: false
|
35
|
-
version_requirements: *2153490500
|
24
|
+
version_requirements: *70179246615980
|
36
25
|
- !ruby/object:Gem::Dependency
|
37
26
|
name: grit
|
38
|
-
requirement: &
|
27
|
+
requirement: &70179246615400 !ruby/object:Gem::Requirement
|
39
28
|
none: false
|
40
29
|
requirements:
|
41
30
|
- - ~>
|
@@ -43,7 +32,7 @@ dependencies:
|
|
43
32
|
version: '2.4'
|
44
33
|
type: :runtime
|
45
34
|
prerelease: false
|
46
|
-
version_requirements: *
|
35
|
+
version_requirements: *70179246615400
|
47
36
|
description: A gem to assist with git workflow, similar to git-flow.
|
48
37
|
email:
|
49
38
|
- peakpg@gmail.com
|
@@ -58,8 +47,12 @@ files:
|
|
58
47
|
- README.md
|
59
48
|
- Rakefile
|
60
49
|
- bin/gd
|
50
|
+
- features/cli.feature
|
51
|
+
- features/step_definitions/cli_steps.rb
|
52
|
+
- features/support.rb/env.rb
|
61
53
|
- git_er_done.gemspec
|
62
54
|
- lib/git_er_done.rb
|
55
|
+
- lib/git_er_done/actions.rb
|
63
56
|
- lib/git_er_done/app.rb
|
64
57
|
- lib/git_er_done/version.rb
|
65
58
|
homepage: ''
|
@@ -82,8 +75,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
75
|
version: '0'
|
83
76
|
requirements: []
|
84
77
|
rubyforge_project: git_er_done
|
85
|
-
rubygems_version: 1.8.
|
78
|
+
rubygems_version: 1.8.10
|
86
79
|
signing_key:
|
87
80
|
specification_version: 3
|
88
81
|
summary: A gem to assist with git workflow.
|
89
|
-
test_files:
|
82
|
+
test_files:
|
83
|
+
- features/cli.feature
|
84
|
+
- features/step_definitions/cli_steps.rb
|
85
|
+
- features/support.rb/env.rb
|