thegarage-gitx 2.3.0.pre1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/thegarage/gitx/cli/base_command.rb +0 -26
- data/lib/thegarage/gitx/cli/cleanup_command.rb +17 -7
- data/lib/thegarage/gitx/cli/review_command.rb +1 -1
- data/lib/thegarage/gitx/thor_extensions.rb +12 -0
- data/lib/thegarage/gitx/version.rb +1 -1
- data/spec/thegarage/gitx/cli/cleanup_command_spec.rb +2 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6700841a12c4d93f59977bba1870d434d2cb6610
|
4
|
+
data.tar.gz: 6a4230ce7ffe3ffe7b9367b58f53db83d2fd5631
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77738d6c2dbddd45b473dbda6c69bd866774a50242be7e48e8d21d2170ffa7de31987b7c7f13172b9da4633df44a997abeaf54ebf31532db578a4811b04c33d4
|
7
|
+
data.tar.gz: d8726869143d111f1975b89b9a247966837c7b16ffe65c2a680c9b9f7413df30aed2ffd35459f7319db05072256fba10cd1e78117c2f77ee6a90a741a98cea80
|
data/README.md
CHANGED
@@ -34,6 +34,7 @@ in order to re-assign pull requests.
|
|
34
34
|
options:
|
35
35
|
* `--assign` or `-a` = assign pull request to github user
|
36
36
|
* `--open` or `-o` = open pull request in default web browser.
|
37
|
+
* `--bump` or `-b` = bump an existing pull request by posting a comment to re-review new changes
|
37
38
|
|
38
39
|
|
39
40
|
## git release
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'thor'
|
2
2
|
require 'pathname'
|
3
3
|
require 'rugged'
|
4
|
-
require 'English'
|
5
4
|
require 'thegarage/gitx'
|
6
5
|
|
7
6
|
module Thegarage
|
@@ -37,16 +36,6 @@ module Thegarage
|
|
37
36
|
repo.branches.find(&:head?)
|
38
37
|
end
|
39
38
|
|
40
|
-
# execute a shell command and raise an error if non-zero exit code is returned
|
41
|
-
# return the string output from the command
|
42
|
-
def run_cmd(cmd, options = {})
|
43
|
-
say "$ #{cmd}"
|
44
|
-
output = `#{cmd}`
|
45
|
-
success = $CHILD_STATUS.to_i == 0
|
46
|
-
fail "#{cmd} failed" unless success || options[:allow_failure]
|
47
|
-
output
|
48
|
-
end
|
49
|
-
|
50
39
|
def aggregate_branch?(branch)
|
51
40
|
AGGREGATE_BRANCHES.include?(branch)
|
52
41
|
end
|
@@ -54,21 +43,6 @@ module Thegarage
|
|
54
43
|
def assert_not_protected_branch!(branch, action)
|
55
44
|
raise "Cannot #{action} reserved branch" if RESERVED_BRANCHES.include?(branch) || aggregate_branch?(branch)
|
56
45
|
end
|
57
|
-
|
58
|
-
# retrieve a list of branches
|
59
|
-
def branches(options = {})
|
60
|
-
branches = []
|
61
|
-
args = []
|
62
|
-
args << '-r' if options[:remote]
|
63
|
-
args << "--merged #{options[:merged].is_a?(String) ? options[:merged] : ''}" if options[:merged]
|
64
|
-
output = `git branch #{args.join(' ')}`.split("\n")
|
65
|
-
output.each do |branch|
|
66
|
-
branch = branch.gsub(/\*/, '').strip.split(' ').first
|
67
|
-
branch = branch.split('/').last if options[:remote]
|
68
|
-
branches << branch unless RESERVED_BRANCHES.include?(branch)
|
69
|
-
end
|
70
|
-
branches.uniq
|
71
|
-
end
|
72
46
|
end
|
73
47
|
end
|
74
48
|
end
|
@@ -14,22 +14,32 @@ module Thegarage
|
|
14
14
|
|
15
15
|
say "Deleting local and remote branches that have been merged into "
|
16
16
|
say Thegarage::Gitx::BASE_BRANCH, :green
|
17
|
-
|
17
|
+
merged_branches(remote: true).each do |branch|
|
18
18
|
run_cmd "git push origin --delete #{branch}"
|
19
19
|
end
|
20
|
-
|
20
|
+
merged_branches(remote: false).each do |branch|
|
21
21
|
run_cmd "git branch -d #{branch}"
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
private
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
# @return list of branches that have been merged
|
28
|
+
def merged_branches(options = {})
|
29
|
+
args = []
|
30
|
+
args << '-r' if options[:remote]
|
31
|
+
args << "--merged"
|
32
|
+
output = run_cmd("git branch #{args.join(' ')}").split("\n")
|
33
|
+
branches = output.map do |branch|
|
34
|
+
branch = branch.gsub(/\*/, '').strip.split(' ').first
|
35
|
+
branch = branch.split('/').last if options[:remote]
|
36
|
+
branch
|
37
|
+
end
|
38
|
+
branches.uniq!
|
39
|
+
branches -= RESERVED_BRANCHES
|
40
|
+
branches.reject! { |b| aggregate_branch?(b) }
|
30
41
|
|
31
|
-
|
32
|
-
branches(:merged => true, :remote => true).reject { |b| aggregate_branch?(b) }
|
42
|
+
branches
|
33
43
|
end
|
34
44
|
end
|
35
45
|
end
|
@@ -22,7 +22,7 @@ module Thegarage
|
|
22
22
|
method_option :description, :type => :string, :aliases => '-d', :desc => 'pull request description'
|
23
23
|
method_option :assignee, :type => :string, :aliases => '-a', :desc => 'pull request assignee'
|
24
24
|
method_option :open, :type => :boolean, :aliases => '-o', :desc => 'open the pull request in a web browser'
|
25
|
-
method_option :bump, :type => :boolean, :aliases => '-b', :desc => 'bump an existing
|
25
|
+
method_option :bump, :type => :boolean, :aliases => '-b', :desc => 'bump an existing pull request by posting a comment to re-review new changes'
|
26
26
|
# @see http://developer.github.com/v3/pulls/
|
27
27
|
def review
|
28
28
|
fail 'Github authorization token not found' unless authorization_token
|
@@ -1,5 +1,17 @@
|
|
1
|
+
require 'English'
|
2
|
+
|
1
3
|
class Thor
|
2
4
|
module Actions
|
5
|
+
# execute a shell command and raise an error if non-zero exit code is returned
|
6
|
+
# return the string output from the command
|
7
|
+
def run_cmd(cmd, options = {})
|
8
|
+
say "$ #{cmd}"
|
9
|
+
output = `#{cmd}`
|
10
|
+
success = $CHILD_STATUS.to_i == 0
|
11
|
+
fail "#{cmd} failed" unless success || options[:allow_failure]
|
12
|
+
output
|
13
|
+
end
|
14
|
+
|
3
15
|
# launch configured editor to retreive message/string
|
4
16
|
# see http://osdir.com/ml/ruby-talk/2010-06/msg01424.html
|
5
17
|
# see https://gist.github.com/rkumar/456809
|
@@ -20,13 +20,12 @@ describe Thegarage::Gitx::Cli::CleanupCommand do
|
|
20
20
|
before do
|
21
21
|
allow(cli).to receive(:say)
|
22
22
|
|
23
|
-
expect(cli).to receive(:merged_remote_branches).and_return(%w( merged-remote-feature ))
|
24
|
-
expect(cli).to receive(:merged_local_branches).and_return(%w( merged-local-feature ))
|
25
|
-
|
26
23
|
expect(cli).to receive(:run_cmd).with('git checkout master').ordered
|
27
24
|
expect(cli).to receive(:run_cmd).with('git pull').ordered
|
28
25
|
expect(cli).to receive(:run_cmd).with('git remote prune origin').ordered
|
26
|
+
expect(cli).to receive(:run_cmd).with('git branch -r --merged').and_return("merged-remote-feature").ordered
|
29
27
|
expect(cli).to receive(:run_cmd).with('git push origin --delete merged-remote-feature').ordered
|
28
|
+
expect(cli).to receive(:run_cmd).with('git branch --merged').and_return("merged-local-feature").ordered
|
30
29
|
expect(cli).to receive(:run_cmd).with('git branch -d merged-local-feature').ordered
|
31
30
|
|
32
31
|
cli.cleanup
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thegarage-gitx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.0
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Sonnek
|
@@ -309,9 +309,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
309
309
|
version: '0'
|
310
310
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
311
311
|
requirements:
|
312
|
-
- - "
|
312
|
+
- - ">="
|
313
313
|
- !ruby/object:Gem::Version
|
314
|
-
version:
|
314
|
+
version: '0'
|
315
315
|
requirements: []
|
316
316
|
rubyforge_project:
|
317
317
|
rubygems_version: 2.2.2
|