capita_git 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -14,6 +14,10 @@
14
14
 
15
15
  $ gitc close ([source_branch])
16
16
 
17
+ $ gitc backport ([branch])
18
+
19
+ $ gitc install_autocompletion
20
+
17
21
  === DESCRIPTION
18
22
 
19
23
  *gitc* is a git automation tool used by CAPITA Unternehmensberatung GmbH which comes
@@ -37,6 +41,8 @@ return your correct name and email address.
37
41
 
38
42
  $ gem install capita_git
39
43
 
44
+ $ gitc install_autocomplete
45
+
40
46
  === COMMANDS
41
47
 
42
48
  For detailed explanation of the various commands, please use *gitc help <command>*.
@@ -62,5 +68,11 @@ Available commands currently are:
62
68
  * <close>:
63
69
  Closes a feature branch by updating the source branch, rebasing it onto your feature
64
70
  branch and then merging into the source branch.
71
+
72
+ * <backport>:
73
+ Merges changes from a fix branch into master
74
+
75
+ * <install_autocomplete>:
76
+ Installs/updates and loads gitc autocompletion bash extension
65
77
 
66
78
 
@@ -0,0 +1,23 @@
1
+ _gitc()
2
+ {
3
+ local cur prev tags base
4
+ COMPREPLY=()
5
+ cur="${COMP_WORDS[COMP_CWORD]}"
6
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
7
+ local tags="create update close check backport publish"
8
+
9
+ case "${prev}" in
10
+ update|close|publish)
11
+ local user=`git config user.name | awk '{split($0,a," "); print tolower(substr(a[1],0,1)substr(a[2],0,1))}'`
12
+ state=`git branch 2>&1 > /dev/null`
13
+ if [ $? == "0" ]; then
14
+ local running=$(for x in `git branch | sed s/\*/' '/ | awk '{ print $1 }' | grep ^${user}_`; do echo ${x} ; done )
15
+ COMPREPLY=($(compgen -W "${running}" ${cur}))
16
+ return 0
17
+ fi
18
+ ;;
19
+ esac
20
+
21
+ COMPREPLY=($(compgen -W "${tags}" ${cur}))
22
+ }
23
+ complete -F _gitc gitc
@@ -33,7 +33,12 @@ module CapitaGit
33
33
 
34
34
  manpages = %w(
35
35
  gitc
36
- gitc-check)
36
+ gitc-check
37
+ gitc-create
38
+ gitc-update
39
+ gitc-close
40
+ gitc-backport
41
+ gitc-install_autocomplete)
37
42
 
38
43
  if manpages.include?(command)
39
44
  root = File.expand_path("../man", __FILE__)
@@ -53,6 +58,7 @@ module CapitaGit
53
58
 
54
59
  method_option 'remote', :type => :string
55
60
  desc "check", "Generates a Gemfile into the current working directory"
61
+
56
62
  def check
57
63
  opts = options.dup
58
64
  log :debug, "[DEBUG] Starting action 'check'"
@@ -99,6 +105,7 @@ module CapitaGit
99
105
  end
100
106
 
101
107
  desc "create", "Creates a new feature branch with the given name and optional source branch"
108
+
102
109
  def create(name, source_branch=nil)
103
110
  repo = CapitaGit::Repository.open(Dir.pwd)
104
111
  source_branch = source_branch.nil? ? repo.current_branch.to_s : source_branch
@@ -109,6 +116,7 @@ module CapitaGit
109
116
  end
110
117
 
111
118
  desc "update", "Updates a feature branch your currently on or specified by name"
119
+
112
120
  def update(feature_branch=nil)
113
121
  repo = CapitaGit::Repository.open(Dir.pwd)
114
122
  feature_branch = feature_branch.nil? ? repo.current_branch : feature_branch
@@ -119,6 +127,7 @@ module CapitaGit
119
127
  end
120
128
 
121
129
  desc "close", "Closes a feature branch your currently on or specified by name onto the source branch"
130
+
122
131
  def close(feature_branch=nil)
123
132
  repo = CapitaGit::Repository.open(Dir.pwd)
124
133
  feature_branch = feature_branch.nil? ? repo.current_branch : feature_branch
@@ -128,6 +137,7 @@ module CapitaGit
128
137
  end
129
138
 
130
139
  desc "backport", "Merges changes from a fixbranch into master"
140
+
131
141
  def backport(fix_branch=nil)
132
142
  repo = CapitaGit::Repository.open(Dir.pwd)
133
143
  fix_branch = fix_branch.nil? ? repo.current_branch : fix_branch
@@ -136,6 +146,24 @@ module CapitaGit
136
146
  repo.merge_fixbranch(fix_branch)
137
147
  end
138
148
 
149
+ desc "install_autocomplete", "asd"
150
+
151
+ def install_autocomplete
152
+ root = File.expand_path("../../", __FILE__)
153
+ system "cp #{root}/bash_completion.txt ~/.gitc_completion"
154
+ system "if grep -q 'gitc_completion' ~/.bashrc; then echo 'Done'; else echo '. .gitc_completion' >> ~/.bashrc; . ~/.gitc_completion; fi"
155
+ end
156
+
157
+ desc "publish", "Published a local branch to origin"
158
+
159
+ def publish(branch_name=nil)
160
+ repo = CapitaGit::Repository.open(Dir.pwd)
161
+ branch_name = branch_name.nil? ? repo.current_branch : branch_name
162
+
163
+ log :confirm, "--> Publishing '#{branch_name}' to 'origin"
164
+ repo.publish_branch(branch_name)
165
+ end
166
+
139
167
  desc "runner", "Generates a Gemfile into the current working directory"
140
168
 
141
169
  def runner(command)
@@ -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.3" "GITC Manual"
4
+ .TH "GITC" "5" "February 2011" "GITC 0.1.4" "GITC Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBgitc\fR \- git helper for CAPITA Unternehmensberatung GmbH
@@ -28,6 +28,9 @@
28
28
  \fBgitc\fR backport [branch]
29
29
  .
30
30
  .br
31
+ \fBgitc\fR install_autocomplete
32
+ .
33
+ .br
31
34
  .
32
35
  .SH "DESCRIPTION"
33
36
  \fBgitc\fR is a git automation tool used by CAPITA Unternehmensberatung GmbH\.
@@ -75,4 +78,8 @@ closes a feature branch by updating and merging into the source branch
75
78
  .TP
76
79
  \fIbackport\fR
77
80
  merges changes from a fix branch into master
81
+ .
82
+ .TP
83
+ \fIinstall_autocomplete\fR
84
+ installs/updates and loads gitc autocompletion bash extension
78
85
 
@@ -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.3" "GITC Manual"
4
+ .TH "GITC\-BACKPORT" "1" "February 2011" "GITC 0.1.4" "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.3 February 2011 GITC-BACKPORT(1)
24
+ GITC 0.1.4 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.3" "GITC Manual"
4
+ .TH "GITC\-CHECK" "1" "February 2011" "GITC 0.1.4" "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.3 February 2011 GITC-CHECK(1)
37
+ GITC 0.1.4 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.3" "GITC Manual"
4
+ .TH "GITC\-CLOSE" "1" "February 2011" "GITC 0.1.4" "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.3 February 2011 GITC-CLOSE(1)
38
+ GITC 0.1.4 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.3" "GITC Manual"
4
+ .TH "GITC\-CREATE" "1" "February 2011" "GITC 0.1.4" "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.3 February 2011 GITC-CREATE(1)
36
+ GITC 0.1.4 February 2011 GITC-CREATE(1)
@@ -0,0 +1,15 @@
1
+ .\" generated with Ronn/v0.7.3
2
+ .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
+ .
4
+ .TH "GITC\-INSTALL_AUTOCOMPLETE" "1" "February 2011" "GITC 0.1.4" "GITC Manual"
5
+ .
6
+ .SH "NAME"
7
+ \fBgitc\-install_autocomplete\fR \- Installs gitc autocompletion
8
+ .
9
+ .SH "SYNOPSIS"
10
+ \fBgitc\fR install_autocomplete
11
+ .
12
+ .br
13
+ .
14
+ .SH "DESCRIPTION"
15
+ \fBgitc autocomplete\fR installs a script in ~/\.gitc_autocomplete, appends inclusion in ~/\.bashrc and sources into current shell\.
@@ -0,0 +1,17 @@
1
+ GITC-INSTALL_AUTOCOMPLETE(1) GITC Manual GITC-INSTALL_AUTOCOMPLETE(1)
2
+
3
+
4
+
5
+ NAME
6
+ gitc-install_autocomplete - Installs gitc autocompletion
7
+
8
+ SYNOPSIS
9
+ gitc install_autocomplete
10
+
11
+ DESCRIPTION
12
+ gitc autocomplete installs a script in ~/.gitc_autocomplete, appends
13
+ inclusion in ~/.bashrc and sources into current shell.
14
+
15
+
16
+
17
+ GITC 0.1.4 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.3" "GITC Manual"
4
+ .TH "GITC\-UPDATE" "1" "February 2011" "GITC 0.1.4" "GITC Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBgitc\-update\fR \- Update a feature branch
@@ -36,4 +36,4 @@ EXAMPLES
36
36
 
37
37
 
38
38
 
39
- GITC 0.1.3 February 2011 GITC-UPDATE(1)
39
+ GITC 0.1.4 February 2011 GITC-UPDATE(1)
@@ -13,6 +13,7 @@ SYNOPSIS
13
13
  gitc update [branch]
14
14
  gitc close [branch]
15
15
  gitc backport [branch]
16
+ gitc install_autocomplete
16
17
 
17
18
  DESCRIPTION
18
19
  gitc is a git automation tool used by CAPITA Unternehmensberatung GmbH.
@@ -52,7 +53,10 @@ COMMANDS
52
53
  backport
53
54
  merges changes from a fix branch into master
54
55
 
56
+ install_autocomplete
57
+ installs/updates and loads gitc autocompletion bash extension
55
58
 
56
59
 
57
60
 
58
- GITC 0.1.3 February 2011 GITC(5)
61
+
62
+ GITC 0.1.4 February 2011 GITC(5)
@@ -92,8 +92,21 @@ module CapitaGit
92
92
  system "git merge -m 'Backporting changes of fix branch \'#{branch}\' into master' #{branch}"
93
93
  end
94
94
 
95
+ def publish_branch(branch)
96
+ raise "Can't publish '#{branch}' since it doesn't exist!" unless has_local_branch?(branch)
97
+ raise "'#{remote_name(branch)}' already exists remotely!" if has_remote_branch?(remote_name(branch))
98
+ push_local_branch_to_remote('origin', branch, remote_name(branch))
99
+ create_local_branch(remote_name(branch), "origin/#{remote_name(branch)}", true)
100
+ checkout_local_branch remote_name(branch)
101
+ system "git branch -D #{branch}"
102
+ end
103
+
95
104
  def has_local_branch?(name)
96
- !@repository.branches.local.detect { |b| b.full =~ /#{name.gsub('/', '\/')}/ }.nil?
105
+ !@repository.branches.local.detect { |b| b.full =~ /^#{name}.*/ }.nil?
106
+ end
107
+
108
+ def has_remote_branch?(name)
109
+ !@repository.branches.remote.detect { |b| b.full =~ /^#{name}.*/ }.nil?
97
110
  end
98
111
 
99
112
  def is_local_feature_branch?(name)
@@ -165,6 +178,10 @@ module CapitaGit
165
178
  name.split('_')[1]
166
179
  end
167
180
 
181
+ def remote_name(name)
182
+ name.gsub(/#{user_shortcut}_/, '').gsub(/_/,'-')
183
+ end
184
+
168
185
  private
169
186
 
170
187
  def log(message)
@@ -1,3 +1,3 @@
1
1
  module CapitaGit
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
data/lib/capita_git.rb CHANGED
@@ -24,3 +24,7 @@ module CapitaGit
24
24
  class RepositoryError < StandardError
25
25
  end
26
26
  end
27
+
28
+ Gem.post_install do |installer|
29
+ puts "!!! #{installer.spec.full_name} INSTALLED !!!"
30
+ end
@@ -0,0 +1,10 @@
1
+ gitc-install_autocomplete(1) -- Installs gitc autocompletion
2
+ =======================================================
3
+
4
+ ## SYNOPSIS
5
+
6
+ `gitc` install_autocomplete<br>
7
+
8
+ ## DESCRIPTION
9
+
10
+ **gitc autocomplete** installs a script in ~/.gitc_autocomplete, appends inclusion in ~/.bashrc and sources into current shell.
data/man/gitc.ronn CHANGED
@@ -10,6 +10,7 @@ gitc(5) -- git helper for CAPITA Unternehmensberatung GmbH
10
10
  `gitc` update [branch]<br>
11
11
  `gitc` close [branch]<br>
12
12
  `gitc` backport [branch]<br>
13
+ `gitc` install_autocomplete<br>
13
14
 
14
15
  ## DESCRIPTION
15
16
 
@@ -49,3 +50,6 @@ Available commands currently are:
49
50
 
50
51
  * <backport>:
51
52
  merges changes from a fix branch into master
53
+
54
+ * <install_autocomplete>:
55
+ installs/updates and loads gitc autocompletion bash extension
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capita_git
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 3
10
- version: 0.1.3
9
+ - 4
10
+ version: 0.1.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sebastian Georgi
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-02-03 00:00:00 +01:00
19
+ date: 2011-02-04 00:00:00 +01:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -115,6 +115,7 @@ files:
115
115
  - Rakefile
116
116
  - bin/gitc
117
117
  - capita_git.gemspec
118
+ - lib/bash_completion.txt
118
119
  - lib/capita_git.rb
119
120
  - lib/capita_git/cli.rb
120
121
  - lib/capita_git/repository.rb
@@ -124,15 +125,18 @@ files:
124
125
  - man/gitc-check.ronn
125
126
  - man/gitc-close.ronn
126
127
  - man/gitc-create.ronn
128
+ - man/gitc-install_autocomplete.ronn
127
129
  - man/gitc-update.ronn
128
130
  - man/gitc.ronn
129
131
  - test/cli_test.rb
130
132
  - test/shoulda_macros.rb
131
133
  - test/test_helper.rb
132
134
  - lib/capita_git/man/gitc
135
+ - lib/capita_git/man/gitc-install_autocomplete
133
136
  - lib/capita_git/man/gitc-check
134
137
  - lib/capita_git/man/gitc-close
135
138
  - lib/capita_git/man/gitc-update
139
+ - lib/capita_git/man/gitc-install_autocomplete.txt
136
140
  - lib/capita_git/man/gitc-create.txt
137
141
  - lib/capita_git/man/gitc-backport.txt
138
142
  - lib/capita_git/man/gitc-check.txt