mm-git-extend 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ .DS_Store
2
+ .AppleDouble
3
+ .LSOverride
4
+ Icon
5
+
6
+
7
+ # Thumbnails
8
+ ._*
9
+
10
+ # Files that might appear on external disk
11
+ .Spotlight-V100
12
+ .Trashes
13
+
14
+ tmp
15
+ *.gem
16
+
17
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require 'optparse'
4
+
5
+ def git(command)
6
+ system("git " + command)
7
+ end
8
+
9
+ def branch_exists?(branch)
10
+ `git branch`.include? " " + branch
11
+ end
12
+
13
+ def branch_name
14
+ [OPTS[:prefix], ARGV[0]].join("/")
15
+ end
16
+
17
+ abort "git: No branch name given" unless ARGV[0]
18
+
19
+ OPTS = {
20
+ :prefix => 'feat'
21
+ }
22
+
23
+ op = OptionParser.new do |x|
24
+ x.on("-p", "--prefix [OPT]", "Branch prefix") do |n|
25
+ OPTS[:prefix] = n
26
+ end
27
+ end
28
+ op.parse!(ARGV)
29
+
30
+ if branch_exists?(branch_name)
31
+ puts "git: Branch already exists. Switching to '#{branch_name}'"
32
+ git "checkout " + branch_name
33
+ else
34
+ git "checkout -b " + branch_name
35
+ end
@@ -0,0 +1,31 @@
1
+ Feature: feature branch creation
2
+ In order to seperate my code to a feature branch
3
+ As a developer
4
+ I want to create a feature branch
5
+
6
+ Background:
7
+ Given I have a working repo
8
+
9
+ Scenario: Create feat branch
10
+ When I run `git feature test`
11
+ Then I should be on a branch called "feat/test"
12
+
13
+ Scenario: A branch already exists
14
+ Given I have a branch called "feat/test"
15
+ When I run `git feature test`
16
+ Then the output should contain "Branch already exists. Switching to 'feat/test'"
17
+ And I should be on a branch called "feat/test"
18
+
19
+ Scenario: Untracked changes
20
+ Given I have untracked changes
21
+ When I run `git feature test`
22
+ Then I should be on a branch called "feat/test"
23
+
24
+ Scenario: Uncommited changes
25
+ Given I have uncommited changes
26
+ When I run `git feature test`
27
+ Then I should be on a branch called "feat/test"
28
+
29
+ Scenario: run with no branch
30
+ When I run `git feature`
31
+ Then the output should contain "No branch name given"
@@ -0,0 +1,47 @@
1
+ def git(command)
2
+ system("git #{command}")
3
+ end
4
+
5
+ def repo_path(repo)
6
+ "tmp/" + repo
7
+ end
8
+
9
+ def remove_repo(repo)
10
+ FileUtils.rm_rf repo_path(repo)
11
+ end
12
+
13
+ def create_repo(repo)
14
+ FileUtils.mkdir repo_path(repo)
15
+ Dir.chdir repo_path(repo)
16
+ FileUtils.touch 'readme.txt'
17
+ git 'init'
18
+ git 'add -A'
19
+ git 'commit -m "init"'
20
+ end
21
+
22
+ Given /^I have a branch called "(.*?)"$/ do |branch|
23
+ git 'checkout -b ' + branch
24
+ FileUtils.touch 'feature_file.txt'
25
+ git 'add -A'
26
+ git 'commit -m "init"'
27
+ git 'checkout master'
28
+ end
29
+
30
+ Given /^I have a working repo$/ do
31
+ remove_repo("git_repo")
32
+ create_repo("git_repo")
33
+ end
34
+
35
+ Then /^I should be on a branch called "(.*?)"$/ do |branch|
36
+ current_branch = `git rev-parse --abbrev-ref HEAD`.strip
37
+ current_branch.should == branch
38
+ end
39
+
40
+ Given /^I have uncommited changes$/ do
41
+ FileUtils.touch 'uncommited.txt'
42
+ git "add -A"
43
+ end
44
+
45
+ Given /^I have untracked changes$/ do
46
+ FileUtils.touch 'untracked.txt'
47
+ end
@@ -0,0 +1,5 @@
1
+ require 'aruba/cucumber'
2
+
3
+ ENV['PATH'] = "#{Dir.getwd}/bin#{File::PATH_SEPARATOR}#{ENV['PATH']}"
4
+
5
+
@@ -0,0 +1,17 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "mm-git-extend"
3
+ s.version = "0.1.0"
4
+ s.platform = Gem::Platform::RUBY
5
+ s.authors = ["Mark McConachie"]
6
+ s.email = ["mark@markmcconachie.com"]
7
+ s.homepage = "http://markmcconachie.com"
8
+ s.summary = %q{Mark's Git extensions}
9
+ s.description = %q{Some (hopefully) userful git extensions}
10
+
11
+ s.add_development_dependency "cucumber"
12
+ s.add_development_dependency "aruba"
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ end
@@ -0,0 +1,13 @@
1
+ # Git extensions
2
+
3
+ Some git extensions
4
+
5
+ ## Feature
6
+
7
+ Creates feature branches with a feat/ prefix.
8
+ Takes an argument --prefix to determin the prefix.
9
+
10
+ ## Useful aliases
11
+
12
+ git config --global alias.feat 'feature -p exp'
13
+ git config --global alias.exp 'feature -p exp'
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mm-git-extend
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Mark McConachie
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-25 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: cucumber
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: aruba
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Some (hopefully) userful git extensions
47
+ email:
48
+ - mark@markmcconachie.com
49
+ executables:
50
+ - git-feature
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - .gitignore
55
+ - Gemfile
56
+ - bin/git-feature
57
+ - features/git-feature.feature
58
+ - features/step_definitions/git_steps.rb
59
+ - features/support/env.rb
60
+ - mm-git-extend.gemspec
61
+ - readme.md
62
+ homepage: http://markmcconachie.com
63
+ licenses: []
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ! '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 1.8.23
83
+ signing_key:
84
+ specification_version: 3
85
+ summary: Mark's Git extensions
86
+ test_files: []