git_er_done 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use 1.9.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in git_er_done.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,47 @@
1
+ Git 'Er Done is a ruby tool for automating common git operations. It's similiar in concept to git flow (https://github.com/nvie/gitflow) but implements a simpler branching model.
2
+
3
+ ## Reasons for this project
4
+
5
+ This project exists for a few reasons:
6
+
7
+ 1. I have a terrible memory for command line syntax, so I want something that reduces the number of commands I have to remember to do things right.
8
+ 2. I want to understand more how to configure git process flows (much like git-flow) does, but have more configurability (via Ruby)
9
+ 3. Gives an interesting test case for my Thor talk at DCRUG and Arlington RUG.
10
+ 4. Make doing the 'right' thing easy (i.e. feature branches should be simple. Smaller projects)
11
+
12
+ ## Syntax
13
+
14
+ Things you can do:
15
+
16
+ ```
17
+ gd - Lists all available commands.
18
+ gd help <command> - Get help for a specific command.
19
+ gd feature new_widget - Creates a new feature branch with the name 'new_widget'.
20
+ gd done new_widget - Completes a feature branch with the name 'new_widget' (Commit, squash, merge and delete branch).
21
+ gd done - Completes the current feature branch you are on.
22
+ gd squash - Condenses multiple commits for the current branch into a single commit.
23
+ gd sync - Brings your branch up to date with the latest version (Use before finishing a feature)
24
+ ```
25
+
26
+ ## Goals
27
+
28
+ Here's what I want to be able to support
29
+
30
+ * Creating and closing feature branches should be simple.
31
+ * Small projects that can work from and merge to master shouldn't need a 'develop' branch.
32
+ * Should automatically squashing commits from feature branches into a single commit via rebase
33
+ * Support git-flow's Feature, hotfix, release branches to/from develop if necessary.
34
+ * Provide a nice discoverable CLI for doing this sort of thing.
35
+
36
+ ## Todo
37
+
38
+ * Improve error messages for incorrectly supplied parameters. (i.e. gd feature)
39
+ * If you gd sync with unstaged changes, it should not switch branches. (It does, which is probably wrong)
40
+ * Figure out how to unit test this.
41
+ * Better error checking (merges failing may cause problems)
42
+
43
+ ## References
44
+
45
+ http://reinh.com/blog/2009/03/02/a-git-workflow-for-agile-teams.html - Target workflow
46
+ http://grit.rubyforge.org/ - A Ruby wrapper around git: Might be useful for more indepth interaction with git.
47
+ http://stackoverflow.com/questions/5294069/best-way-to-create-an-executable-for-a-gem-using-rake - Minimum work to make a CLI bin file.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
data/bin/gd ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
3
+ $LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
4
+ require 'git_er_done'
5
+
6
+ Git::Er::Done::App.start
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "git_er_done/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "git_er_done"
7
+ s.version = Git::Er::Done::VERSION
8
+ s.authors = ["peakpg"]
9
+ s.email = ["peakpg@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{A gem to assist with git workflow.}
12
+ s.description = %q{A gem to assist with git workflow, similar to git-flow.}
13
+
14
+ s.rubyforge_project = "git_er_done"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ [['thor', '~> 0.14.6'], ['rails', '~> 3.0.9'], ['grit', '~>2.4']].each do |gem, version|
22
+ s.add_dependency(gem, version)
23
+ end
24
+ end
@@ -0,0 +1,2 @@
1
+ require "git_er_done/version"
2
+ require 'git_er_done/app'
@@ -0,0 +1,80 @@
1
+ require 'thor'
2
+ require 'rails/generators/actions'
3
+ require 'grit'
4
+
5
+ module Git
6
+ module Er
7
+ module Done
8
+ class App < Thor
9
+
10
+ include Thor::Actions
11
+ include Rails::Generators::Actions
12
+
13
+ FEATURES_PATH = "features/"
14
+
15
+ desc 'feature [NAME]', 'Start a new feature using a branch.'
16
+ def feature(name)
17
+ puts "Creating a new feature called #{feature_branch(name)}."
18
+ git :checkout => "-b #{feature_branch(name)}"
19
+ end
20
+
21
+ # Add everything, commit it, merge it back into the main branch.
22
+ desc 'done (NAME)', 'Completes a feature (commits, squashes then merges into master). Call sync before doing this.'
23
+ def done(name=nil)
24
+ unless name
25
+ name = current_feature
26
+ end
27
+ puts "Completing a feature called #{feature_branch(name)}"
28
+ git :add=>"."
29
+ git :commit
30
+ squash
31
+ # Should we also sync with master first?
32
+ git :checkout => 'master'
33
+ git :merge => feature_branch(name)
34
+ git :branch => "-d #{feature_branch(name)}"
35
+ end
36
+
37
+ desc 'squash', 'Squash all commits from the current branch into a single commit.'
38
+ def squash
39
+ # Squash all changes since we branched away from master
40
+ git :rebase => "-i master"
41
+ end
42
+
43
+ desc 'sync', 'Update your branch with the latest from master.'
44
+ def sync
45
+ return_to_branch = current_branch
46
+ git :checkout => :master
47
+ git :pull
48
+ git :checkout => return_to_branch
49
+ git :rebase => :master
50
+ end
51
+
52
+ private
53
+
54
+ # Returns the name of the feature for the current branch
55
+ # @return [String] Name of feature (not include features/)
56
+ def current_feature
57
+ b = current_branch
58
+ if b.start_with?(FEATURES_PATH)
59
+ return b[FEATURES_PATH.length, b.length]
60
+ end
61
+ return ""
62
+ end
63
+
64
+ def current_branch
65
+ repo.head.name
66
+ end
67
+
68
+ def repo
69
+ repo ||= Grit::Repo.new('.')
70
+ end
71
+
72
+ def feature_branch(name)
73
+ "#{FEATURES_PATH}#{name}"
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
79
+
80
+
@@ -0,0 +1,7 @@
1
+ module Git
2
+ module Er
3
+ module Done
4
+ VERSION = "0.1.0"
5
+ end
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: git_er_done
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - peakpg
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-07-28 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: thor
16
+ requirement: &2153491080 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.14.6
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *2153491080
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
36
+ - !ruby/object:Gem::Dependency
37
+ name: grit
38
+ requirement: &2153490080 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: '2.4'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *2153490080
47
+ description: A gem to assist with git workflow, similar to git-flow.
48
+ email:
49
+ - peakpg@gmail.com
50
+ executables:
51
+ - gd
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - .gitignore
56
+ - .rvmrc
57
+ - Gemfile
58
+ - README.md
59
+ - Rakefile
60
+ - bin/gd
61
+ - git_er_done.gemspec
62
+ - lib/git_er_done.rb
63
+ - lib/git_er_done/app.rb
64
+ - lib/git_er_done/version.rb
65
+ homepage: ''
66
+ licenses: []
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ requirements: []
84
+ rubyforge_project: git_er_done
85
+ rubygems_version: 1.8.5
86
+ signing_key:
87
+ specification_version: 3
88
+ summary: A gem to assist with git workflow.
89
+ test_files: []