capita_git 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -4,3 +4,4 @@ pkg/*
4
4
  .idea
5
5
  lib/capita_git/man
6
6
  tmp/*
7
+ coverage
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- capita_git (0.1.4)
4
+ capita_git (0.1.5)
5
5
  git (>= 1.2.5)
6
6
  thor (>= 0.14.6)
7
7
 
@@ -18,6 +18,9 @@ GEM
18
18
  mustache (>= 0.7.0)
19
19
  rdiscount (>= 1.5.8)
20
20
  shoulda (2.11.3)
21
+ simplecov (0.3.9)
22
+ simplecov-html (>= 0.3.7)
23
+ simplecov-html (0.3.9)
21
24
  thor (0.14.6)
22
25
 
23
26
  PLATFORMS
@@ -25,6 +28,9 @@ PLATFORMS
25
28
 
26
29
  DEPENDENCIES
27
30
  capita_git!
31
+ git (>= 1.2.5)
28
32
  open4
29
33
  ronn (>= 0.7.3)
30
34
  shoulda (>= 2.11.0)
35
+ simplecov
36
+ thor (>= 0.14.6)
data/bin/gitc CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- require 'capita_git'
2
+ require File.join(File.dirname(__FILE__), '../lib/capita_git')
3
3
 
4
4
  begin
5
5
  CapitaGit::CLI.start
data/capita_git.gemspec CHANGED
@@ -24,4 +24,5 @@ Gem::Specification.new do |s|
24
24
  s.add_development_dependency('ronn', ">= 0.7.3")
25
25
  s.add_development_dependency('shoulda', ">= 2.11.0")
26
26
  s.add_development_dependency('open4')
27
+ s.add_development_dependency('simplecov')
27
28
  end
@@ -12,7 +12,11 @@ module CapitaGit
12
12
  class_eval do
13
13
  desc "#{cmd}", "Passes #{cmd} to git"
14
14
  define_method cmd.to_sym do |*args|
15
- log :warn, 'You called a git command from gitc, passing it along for now...'
15
+ log :warn, 'You called a git command from gitc...'
16
+ 3.downto(1) do |i|
17
+ log :warn, "Executing in #{i}"
18
+ sleep 1
19
+ end
16
20
  system "git #{cmd} #{args}"
17
21
  end
18
22
  end
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "GITC" "5" "February 2011" "GITC 0.1.5" "GITC Manual"
4
+ .TH "GITC" "5" "February 2011" "GITC 0.1.6" "GITC Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBgitc\fR \- git helper for CAPITA Unternehmensberatung GmbH
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "GITC\-BACKPORT" "1" "February 2011" "GITC 0.1.5" "GITC Manual"
4
+ .TH "GITC\-BACKPORT" "1" "February 2011" "GITC 0.1.6" "GITC Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBgitc\-backport\fR \- Ports changes from a fix branch into master
@@ -21,4 +21,4 @@ EXAMPLES
21
21
 
22
22
 
23
23
 
24
- GITC 0.1.5 February 2011 GITC-BACKPORT(1)
24
+ GITC 0.1.6 February 2011 GITC-BACKPORT(1)
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "GITC\-CHECK" "1" "February 2011" "GITC 0.1.5" "GITC Manual"
4
+ .TH "GITC\-CHECK" "1" "February 2011" "GITC 0.1.6" "GITC Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBgitc\-check\fR \- Check for releases and create branches
@@ -34,4 +34,4 @@ DESCRIPTION
34
34
 
35
35
 
36
36
 
37
- GITC 0.1.5 February 2011 GITC-CHECK(1)
37
+ GITC 0.1.6 February 2011 GITC-CHECK(1)
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "GITC\-CLOSE" "1" "February 2011" "GITC 0.1.5" "GITC Manual"
4
+ .TH "GITC\-CLOSE" "1" "February 2011" "GITC 0.1.6" "GITC Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBgitc\-close\fR \- Closes a feature branch
@@ -35,4 +35,4 @@ EXAMPLES
35
35
 
36
36
 
37
37
 
38
- GITC 0.1.5 February 2011 GITC-CLOSE(1)
38
+ GITC 0.1.6 February 2011 GITC-CLOSE(1)
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "GITC\-CREATE" "1" "February 2011" "GITC 0.1.5" "GITC Manual"
4
+ .TH "GITC\-CREATE" "1" "February 2011" "GITC 0.1.6" "GITC Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBgitc\-create\fR \- Creates a feature branch
@@ -33,4 +33,4 @@ EXAMPLES
33
33
 
34
34
 
35
35
 
36
- GITC 0.1.5 February 2011 GITC-CREATE(1)
36
+ GITC 0.1.6 February 2011 GITC-CREATE(1)
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "GITC\-INSTALL_AUTOCOMPLETE" "1" "February 2011" "GITC 0.1.5" "GITC Manual"
4
+ .TH "GITC\-INSTALL_AUTOCOMPLETE" "1" "February 2011" "GITC 0.1.6" "GITC Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBgitc\-install_autocomplete\fR \- Installs gitc autocompletion
@@ -14,4 +14,4 @@ DESCRIPTION
14
14
 
15
15
 
16
16
 
17
- GITC 0.1.5 February 2011 GITC-INSTALL_AUTOCOMPLETE(1)
17
+ GITC 0.1.6 February 2011 GITC-INSTALL_AUTOCOMPLETE(1)
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "GITC\-UPDATE" "1" "February 2011" "GITC 0.1.5" "GITC Manual"
4
+ .TH "GITC\-UPDATE" "1" "February 2011" "GITC 0.1.6" "GITC Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBgitc\-update\fR \- Update a feature branch
@@ -15,25 +15,25 @@ DESCRIPTION
15
15
  branch is checked out and updated via git pull and the feature branch
16
16
  gets rebased with any new changeset from the source branch. In case of
17
17
  an unsuccessful rebase, the user needs to proceed as normal (e.g.
18
- resolving conflicts, issuing 'git add .' and 'git rebase --continue').
18
+ resolving conflicts, issuing 'git add .' and 'git rebase --continue').
19
19
 
20
- Gitc will fail if the source branch doesn't exist or is a feature
20
+ Gitc will fail if the source branch doesn't exist or is a feature
21
21
  branch itself!
22
22
 
23
23
  EXAMPLES
24
24
  'gitc update'
25
- called out of the feature branch 'jd_master_my-feature' would
25
+ called out of the feature branch 'jd_master_my-feature' would
26
26
  result in updating 'master' and doing a rebase
27
- (git checkout master && git pull && git checkout jd_mas-
27
+ (git checkout master && git pull && git checkout jd_mas-
28
28
  ter_my-feature && git rebase master)
29
29
 
30
30
  'gitc update'
31
- called out of the feature branch 'jd_2.0-fix_my-feature' would
31
+ called out of the feature branch 'jd_2.0-fix_my-feature' would
32
32
  result in updating '2.0-fix' and doing a rebase
33
- (git checkout 2.0-fix && git pull && git checkout
33
+ (git checkout 2.0-fix && git pull && git checkout
34
34
  jd_2.0-fix_my-feature && git rebase 2.0-fix)
35
35
 
36
36
 
37
37
 
38
38
 
39
- GITC 0.1.5 February 2011 GITC-UPDATE(1)
39
+ GITC 0.1.6 February 2011 GITC-UPDATE(1)
@@ -18,14 +18,14 @@ SYNOPSIS
18
18
  DESCRIPTION
19
19
  gitc is a git automation tool used by CAPITA Unternehmensberatung GmbH.
20
20
 
21
- It's main purpose is to automate repetivite tasks as spawing new fea-
22
- ture branches, updating and rebasing from the source branch of a given
23
- feature branch, as well as closing/merging feature branchs back into
21
+ It's main purpose is to automate repetivite tasks as spawing new fea-
22
+ ture branches, updating and rebasing from the source branch of a given
23
+ feature branch, as well as closing/merging feature branchs back into
24
24
  their originating timeline.
25
25
 
26
- gict uses a strict naming convention for creating, idenfitying and
27
- maintaining local and remote branches and depends on the users's name
28
- being set in the git configuration of your local cloned copy or in the
26
+ gict uses a strict naming convention for creating, idenfitying and
27
+ maintaining local and remote branches and depends on the users's name
28
+ being set in the git configuration of your local cloned copy or in the
29
29
  global settings.
30
30
 
31
31
  Please make sure that both
@@ -34,20 +34,20 @@ DESCRIPTION
34
34
  return your correct name and email address.
35
35
 
36
36
  COMMANDS
37
- For detailed explanation of the various commands, please use gitc help
37
+ For detailed explanation of the various commands, please use gitc help
38
38
  command.
39
39
 
40
40
  Available commands currently are:
41
41
 
42
- check performs a basic check of your repository, as well as maintains
42
+ check performs a basic check of your repository, as well as maintains
43
43
  fixbranches for major release tags both locally and remotely
44
44
 
45
45
  create creates a feature branch
46
46
 
47
- update updates the feature branch's source branch and rebases the fea-
47
+ update updates the feature branch's source branch and rebases the fea-
48
48
  ture branch
49
49
 
50
- close closes a feature branch by updating and merging into the source
50
+ close closes a feature branch by updating and merging into the source
51
51
  branch
52
52
 
53
53
  backport
@@ -57,9 +57,9 @@ COMMANDS
57
57
  installs/updates and loads gitc autocompletion bash extension
58
58
 
59
59
  GIT-PASSTHROUGH
60
- If gitc is called with a default git-command it will pass on both com-
60
+ If gitc is called with a default git-command it will pass on both com-
61
61
  mand and arguments to git after displaying a short warning
62
62
 
63
63
 
64
64
 
65
- GITC 0.1.5 February 2011 GITC(5)
65
+ GITC 0.1.6 February 2011 GITC(5)
@@ -163,11 +163,11 @@ module CapitaGit
163
163
  end
164
164
 
165
165
  def user_name
166
- @repository.config('user.name')
166
+ @user_name ||= `git config --get user.name`.strip.chomp
167
167
  end
168
168
 
169
169
  def user_email
170
- @repository.config('user.email')
170
+ @user_email ||= `git config --get user.email`.strip.chomp
171
171
  end
172
172
 
173
173
  def user_shortcut
@@ -1,3 +1,3 @@
1
1
  module CapitaGit
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
data/test/cli_test.rb CHANGED
@@ -6,8 +6,6 @@ class CliTest < Test::Unit::TestCase
6
6
  after('git pull') { should_have_tag '1.0' }
7
7
 
8
8
  should('respond to git-cmd #status') { assert_command_match 'gitc status', "nothing to commit" }
9
- should('respond to git-cmd #pull') { assert_command_match 'gitc pull', "Already up-to-date" }
10
- should('respond to git-cmd #push') { assert_command_match 'gitc push', "Everything up-to-date" }
11
9
 
12
10
  gitc 'check' do
13
11
  should_have_branch '1.0-fix'
@@ -37,17 +35,60 @@ class CliTest < Test::Unit::TestCase
37
35
  should_have_file 'fixfile', :in => 'local_checkout_1'
38
36
  end
39
37
  end
40
-
41
38
  end
42
39
  end
43
40
  end
44
41
 
45
- gitc 'create my_feature' do
46
- should "be on branch USER_master_my_feature" do
47
- user = CapitaGit::Repository.open('.').user_shortcut
48
- assert_equal "#{user}_master_my_feature", repo.current_branch
42
+ context 'being on the fix-branch' do
43
+ setup do
44
+ assert_command 'gitc check'
45
+ assert_command 'git checkout 1.0-fix'
46
+ end
47
+ should_be_on_branch '1.0-fix'
48
+
49
+ context 'create my-feature' do
50
+ setup { assert_command 'gitc create my-feature' }
51
+ should_be_on_user_branch "1.0-fix_my-feature"
52
+
53
+ context 'after creating a fix' do
54
+ setup do
55
+ assert_command 'echo "foo" > fixfile2'
56
+ assert_command 'git add . && git commit -m "fixfile2"'
57
+ end
58
+ should_be_on_user_branch "1.0-fix_my-feature"
59
+ should_have_file 'fixfile2', :in => 'local_checkout_1'
60
+
61
+ context 'and closing it' do
62
+ setup do
63
+ assert_command 'gitc close'
64
+ end
65
+ should_be_on_branch "1.0-fix"
66
+ should_have_file 'fixfile2', :in => 'local_checkout_1'
67
+
68
+ context 'and backporting it' do
69
+ setup do
70
+ assert_command 'gitc backport'
71
+ assert_command 'git push'
72
+ end
73
+ should_be_on_branch "master"
74
+
75
+ context "after pull and checkout of master in checkout 2" do
76
+ setup do
77
+ in_dir 'local_checkout_2' do
78
+ assert_command 'git checkout master'
79
+ assert_command 'git pull'
80
+ end
81
+ end
82
+ should_have_file 'fixfile2', :in => 'local_checkout_2'
83
+ end
84
+ end
85
+ end
86
+ end
49
87
  end
88
+ end
50
89
 
90
+ gitc 'create my_feature' do
91
+ should_be_on_user_branch "master_my_feature"
51
92
  should_not_have_file 'awesome_feature', :in => 'local_checkout_1'
52
93
 
53
94
  should "break trying to create another feature branch from existing feature branch" do
@@ -72,18 +113,6 @@ class CliTest < Test::Unit::TestCase
72
113
  should_have_file 'master_2_update', :in => 'local_checkout_1'
73
114
  end
74
115
 
75
- # context "while having the same file changed in origin" do
76
- # setup do
77
- # in_dir 'local_checkout_1' do
78
- # assert_command 'echo "foo" > master_2_update'
79
- # assert_command 'git add . && git commit -m "master 2 update"'
80
- # end
81
- # end
82
- #
83
- # should "crash on invoking 'gitc update'" do
84
- # assert_command_fail("#{ShouldaMacros::BIN_PATH} update")
85
- # end
86
- # end
87
116
  end
88
117
 
89
118
  # Committing a fix and closing branch
@@ -1,5 +1,7 @@
1
+ require 'digest/sha1'
2
+
1
3
  module ShouldaMacros
2
- TEMP_DIR = File.expand_path('/tmp/capita_git_tmp')
4
+ TEMP_DIR = File.expand_path("/tmp/capita_git_tmp-#{Digest::SHA1.hexdigest("#{Time.now}#{rand(99999)}")}")
3
5
  BIN_PATH = File.expand_path(File.join(File.dirname(__FILE__), '..', 'bin/gitc'))
4
6
 
5
7
  # Test method level helpers
@@ -91,7 +93,9 @@ module ShouldaMacros
91
93
 
92
94
  # Make sure the temporary directory is purged after every run
93
95
  teardown do
94
- FileUtils.rm_rf(temp_dir)
96
+ Dir.chdir('/tmp') do
97
+ FileUtils.rm_rf(ShouldaMacros::TEMP_DIR)
98
+ end
95
99
  end
96
100
  end
97
101
  end
@@ -129,6 +133,17 @@ module ShouldaMacros
129
133
  end
130
134
  end
131
135
 
136
+ def should_be_on_branch(name, user=false)
137
+ should "be on branch '#{name}'" do
138
+ branch = user ? "#{CapitaGit::Repository.open('.').user_shortcut}_#{name}" : name
139
+ assert_equal branch, CapitaGit::Repository.open('.').current_branch
140
+ end
141
+ end
142
+
143
+ def should_be_on_user_branch(name)
144
+ should_be_on_branch(name, true)
145
+ end
146
+
132
147
  def should_have_branch(name)
133
148
  should "have branch '#{name}'" do
134
149
  assert repo.branches.map(&:name).include?(name), "Found in #{Dir.getwd}: " + repo.branches.map(&:name).inspect
data/test/test_helper.rb CHANGED
@@ -1,11 +1,17 @@
1
1
  require 'rubygems'
2
2
  require 'bundler/setup'
3
+ require 'simplecov'
4
+ SimpleCov.start do
5
+ add_filter "/test/"
6
+ end
7
+
8
+
3
9
  require 'capita_git'
4
10
  require 'git'
5
11
 
12
+ # Test-related libraries
6
13
  require 'test/unit'
7
14
  require 'shoulda'
8
-
9
15
  require 'fileutils'
10
16
  require "open4" # See http://tech.natemurray.com/2007/03/ruby-shell-commands.html
11
17
  require 'shoulda_macros'
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capita_git
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
5
- prerelease:
4
+ prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 1
9
- - 5
10
- version: 0.1.5
8
+ - 6
9
+ version: 0.1.6
11
10
  platform: ruby
12
11
  authors:
13
12
  - Sebastian Georgi
@@ -16,7 +15,7 @@ autorequire:
16
15
  bindir: bin
17
16
  cert_chain: []
18
17
 
19
- date: 2011-02-07 00:00:00 +01:00
18
+ date: 2011-02-08 00:00:00 +01:00
20
19
  default_executable:
21
20
  dependencies:
22
21
  - !ruby/object:Gem::Dependency
@@ -27,7 +26,6 @@ dependencies:
27
26
  requirements:
28
27
  - - ">="
29
28
  - !ruby/object:Gem::Version
30
- hash: 21
31
29
  segments:
32
30
  - 1
33
31
  - 2
@@ -43,7 +41,6 @@ dependencies:
43
41
  requirements:
44
42
  - - ">="
45
43
  - !ruby/object:Gem::Version
46
- hash: 43
47
44
  segments:
48
45
  - 0
49
46
  - 14
@@ -59,7 +56,6 @@ dependencies:
59
56
  requirements:
60
57
  - - ">="
61
58
  - !ruby/object:Gem::Version
62
- hash: 5
63
59
  segments:
64
60
  - 0
65
61
  - 7
@@ -75,7 +71,6 @@ dependencies:
75
71
  requirements:
76
72
  - - ">="
77
73
  - !ruby/object:Gem::Version
78
- hash: 35
79
74
  segments:
80
75
  - 2
81
76
  - 11
@@ -91,12 +86,24 @@ dependencies:
91
86
  requirements:
92
87
  - - ">="
93
88
  - !ruby/object:Gem::Version
94
- hash: 3
95
89
  segments:
96
90
  - 0
97
91
  version: "0"
98
92
  type: :development
99
93
  version_requirements: *id005
94
+ - !ruby/object:Gem::Dependency
95
+ name: simplecov
96
+ prerelease: false
97
+ requirement: &id006 !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ segments:
103
+ - 0
104
+ version: "0"
105
+ type: :development
106
+ version_requirements: *id006
100
107
  description: Git-automation tool for quick handling of common patterns for feature and fix branches
101
108
  email:
102
109
  - sgeorgi@capita.de
@@ -132,19 +139,19 @@ files:
132
139
  - test/shoulda_macros.rb
133
140
  - test/test_helper.rb
134
141
  - lib/capita_git/man/gitc
135
- - lib/capita_git/man/gitc-install_autocomplete
142
+ - lib/capita_git/man/gitc-backport
143
+ - lib/capita_git/man/gitc-backport.txt
136
144
  - lib/capita_git/man/gitc-check
145
+ - lib/capita_git/man/gitc-check.txt
137
146
  - lib/capita_git/man/gitc-close
138
- - lib/capita_git/man/gitc-update
139
- - lib/capita_git/man/gitc-install_autocomplete.txt
147
+ - lib/capita_git/man/gitc-close.txt
148
+ - lib/capita_git/man/gitc-create
140
149
  - lib/capita_git/man/gitc-create.txt
141
- - lib/capita_git/man/gitc-backport.txt
142
- - lib/capita_git/man/gitc-check.txt
150
+ - lib/capita_git/man/gitc-install_autocomplete
151
+ - lib/capita_git/man/gitc-install_autocomplete.txt
152
+ - lib/capita_git/man/gitc-update
143
153
  - lib/capita_git/man/gitc-update.txt
144
154
  - lib/capita_git/man/gitc.txt
145
- - lib/capita_git/man/gitc-close.txt
146
- - lib/capita_git/man/gitc-create
147
- - lib/capita_git/man/gitc-backport
148
155
  has_rdoc: true
149
156
  homepage: https://github.com/capita/capita_git
150
157
  licenses: []
@@ -159,7 +166,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
159
166
  requirements:
160
167
  - - ">="
161
168
  - !ruby/object:Gem::Version
162
- hash: 3
163
169
  segments:
164
170
  - 0
165
171
  version: "0"
@@ -168,14 +174,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
174
  requirements:
169
175
  - - ">="
170
176
  - !ruby/object:Gem::Version
171
- hash: 3
172
177
  segments:
173
178
  - 0
174
179
  version: "0"
175
180
  requirements: []
176
181
 
177
182
  rubyforge_project: capita_git
178
- rubygems_version: 1.5.0
183
+ rubygems_version: 1.3.7
179
184
  signing_key:
180
185
  specification_version: 3
181
186
  summary: Git-automation tool for quick handling of common patterns for feature and fix branches