gitx 2.21.3 → 2.21.4.ci.145.1
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 +13 -5
- data/README.md +0 -4
- data/lib/gitx/cli/base_command.rb +12 -11
- data/lib/gitx/cli/buildtag_command.rb +2 -2
- data/lib/gitx/cli/cleanup_command.rb +6 -6
- data/lib/gitx/cli/integrate_command.rb +6 -11
- data/lib/gitx/cli/nuke_command.rb +7 -8
- data/lib/gitx/cli/release_command.rb +4 -5
- data/lib/gitx/cli/review_command.rb +1 -1
- data/lib/gitx/cli/share_command.rb +2 -2
- data/lib/gitx/cli/track_command.rb +1 -1
- data/lib/gitx/cli/update_command.rb +3 -3
- data/lib/gitx/executor.rb +26 -0
- data/lib/gitx/extensions/thor.rb +0 -22
- data/lib/gitx/github.rb +2 -3
- data/lib/gitx/version.rb +1 -1
- data/spec/gitx/cli/buildtag_command_spec.rb +5 -4
- data/spec/gitx/cli/cleanup_command_spec.rb +11 -8
- data/spec/gitx/cli/integrate_command_spec.rb +55 -70
- data/spec/gitx/cli/nuke_command_spec.rb +25 -27
- data/spec/gitx/cli/release_command_spec.rb +46 -47
- data/spec/gitx/cli/review_command_spec.rb +8 -9
- data/spec/gitx/cli/share_command_spec.rb +4 -3
- data/spec/gitx/cli/start_command_spec.rb +8 -10
- data/spec/gitx/cli/track_command_spec.rb +3 -2
- data/spec/gitx/cli/update_command_spec.rb +12 -11
- data/spec/gitx/executor_spec.rb +41 -0
- metadata +48 -46
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NmZmMzE3ZGYxNzI4YTQ4NzVjMmFmNGM1YjEyY2UxZDE5ZTBiMDY0OQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MmQ5YzNlMWYxZjZjYjU0NmY0MTJiYjZlMTIxZDZlMjA0NDY1MWQ0OQ==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YzVlZTNlYjAwMjRkYzI1Nzc1Y2Y2NTczM2ZjZWM2ODg2NjE3MWQ4NjBlNzdm
|
10
|
+
MGUyMjIwZDg1MzZhNGFlZjgzOWYyNmE1MTRhZjgxMjIxNDEzMGIzNDQxODA3
|
11
|
+
YTI5MmZkZDg0MDFkNmZkNzk3OWY3MzJlMmUzOWMyMjE1YWMzZWE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZjVlMGVkNDczMWI5NTBjYTllNGRiZGE2MjRjZjY3Y2Q4ODU0NWM5YmJjY2Vm
|
14
|
+
ZTYxZDhiMWRkMjUyOGNjOGZhMTVkOTI1YWU3MmUwZGU2YmVjZDVjNzY2N2Vi
|
15
|
+
Njk5YTMwMTYyM2ExZDRhNzc4ZDUzYzM2MzA2ODhlNzg2ZmRmMDU=
|
data/README.md
CHANGED
@@ -15,10 +15,6 @@ so they are available without learning any new commands!
|
|
15
15
|
$ gem install gitx
|
16
16
|
```
|
17
17
|
|
18
|
-
### Global Options
|
19
|
-
* `--trace` or `-v` = verbose output for debugging commands
|
20
|
-
* `--pretend` or `-p` = dry run commands and do not actually invoke operations
|
21
|
-
|
22
18
|
## git start <new_branch_name (optional)>
|
23
19
|
|
24
20
|
update local repository with latest upstream changes and create a new feature branch
|
@@ -2,6 +2,7 @@ require 'thor'
|
|
2
2
|
require 'pathname'
|
3
3
|
require 'rugged'
|
4
4
|
require 'gitx'
|
5
|
+
require 'gitx/executor'
|
5
6
|
|
6
7
|
module Gitx
|
7
8
|
module Cli
|
@@ -12,11 +13,6 @@ module Gitx
|
|
12
13
|
|
13
14
|
add_runtime_options!
|
14
15
|
|
15
|
-
method_option :trace, type: :boolean, aliases: '-v'
|
16
|
-
def initialize(*args)
|
17
|
-
super(*args)
|
18
|
-
end
|
19
|
-
|
20
16
|
private
|
21
17
|
|
22
18
|
def repo
|
@@ -26,12 +22,18 @@ module Gitx
|
|
26
22
|
end
|
27
23
|
end
|
28
24
|
|
25
|
+
def run_cmd(*cmd)
|
26
|
+
executor.execute(*cmd) do |output|
|
27
|
+
say(output, :yellow)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
29
31
|
def run_git_cmd(*cmd)
|
30
32
|
run_cmd('git', *cmd)
|
31
33
|
end
|
32
34
|
|
33
35
|
def checkout_branch(branch_name)
|
34
|
-
|
36
|
+
run_git_cmd 'checkout', branch_name
|
35
37
|
end
|
36
38
|
|
37
39
|
# lookup the current branch of the repo
|
@@ -47,14 +49,13 @@ module Gitx
|
|
47
49
|
fail "Cannot #{action} reserved branch" if config.reserved_branch?(branch) || config.aggregate_branch?(branch)
|
48
50
|
end
|
49
51
|
|
50
|
-
# helper to invoke other CLI commands
|
51
|
-
def execute_command(command_class, method, args = [])
|
52
|
-
command_class.new.send(method, *args)
|
53
|
-
end
|
54
|
-
|
55
52
|
def config
|
56
53
|
@configuration ||= Gitx::Configuration.new(repo.workdir)
|
57
54
|
end
|
55
|
+
|
56
|
+
def executor
|
57
|
+
@executor ||= Gitx::Executor.new
|
58
|
+
end
|
58
59
|
end
|
59
60
|
end
|
60
61
|
end
|
@@ -10,8 +10,8 @@ module Gitx
|
|
10
10
|
method_option :message, type: :string, aliases: '-m', desc: 'message to attach to the buildtag'
|
11
11
|
def buildtag
|
12
12
|
fail "Branch must be one of the supported taggable branches: #{config.taggable_branches}" unless config.taggable_branch?(branch_name)
|
13
|
-
|
14
|
-
|
13
|
+
run_git_cmd 'tag', git_tag, '--annotate', '--message', label
|
14
|
+
run_git_cmd 'push', 'origin', git_tag
|
15
15
|
end
|
16
16
|
|
17
17
|
private
|
@@ -8,16 +8,16 @@ module Gitx
|
|
8
8
|
desc 'cleanup', 'Cleanup branches that have been merged into master from the repo'
|
9
9
|
def cleanup
|
10
10
|
checkout_branch config.base_branch
|
11
|
-
|
12
|
-
|
11
|
+
run_git_cmd 'pull'
|
12
|
+
run_git_cmd 'remote', 'prune', 'origin'
|
13
13
|
|
14
14
|
say 'Deleting local and remote branches that have been merged into '
|
15
15
|
say config.base_branch, :green
|
16
16
|
merged_branches(remote: true).each do |branch|
|
17
|
-
|
17
|
+
run_git_cmd 'push', 'origin', '--delete', branch
|
18
18
|
end
|
19
19
|
merged_branches(remote: false).each do |branch|
|
20
|
-
|
20
|
+
run_git_cmd 'branch', '--delete', branch
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -26,9 +26,9 @@ module Gitx
|
|
26
26
|
# @return list of branches that have been merged
|
27
27
|
def merged_branches(options = {})
|
28
28
|
args = []
|
29
|
-
args << '
|
29
|
+
args << '--remote' if options[:remote]
|
30
30
|
args << '--merged'
|
31
|
-
output =
|
31
|
+
output = run_git_cmd('branch', *args).split("\n")
|
32
32
|
branches = output.map do |branch|
|
33
33
|
branch = branch.gsub(/\*/, '').strip.split(' ').first
|
34
34
|
branch = branch.split('/').last if options[:remote]
|
@@ -16,12 +16,7 @@ module Gitx
|
|
16
16
|
branch = feature_branch_name
|
17
17
|
print_message(branch, integration_branch)
|
18
18
|
|
19
|
-
|
20
|
-
execute_command(UpdateCommand, :update)
|
21
|
-
rescue
|
22
|
-
raise MergeError, 'Merge conflict occurred. Please fix merge conflict and rerun the integrate command'
|
23
|
-
end
|
24
|
-
|
19
|
+
run_git_cmd 'update'
|
25
20
|
pull_request = pull_request_for_branch(branch)
|
26
21
|
integrate_branch(branch, integration_branch, pull_request) unless options[:resume]
|
27
22
|
checkout_branch branch
|
@@ -47,11 +42,11 @@ module Gitx
|
|
47
42
|
commit_message = "[gitx] Integrating #{branch} into #{integration_branch}"
|
48
43
|
commit_message += " (Pull request ##{pull_request.number})" if pull_request
|
49
44
|
begin
|
50
|
-
|
45
|
+
run_git_cmd 'merge', '--no-ff', '--message', commit_message, branch
|
51
46
|
rescue
|
52
47
|
raise MergeError, "Merge conflict occurred. Please fix merge conflict and rerun command with --resume #{branch} flag"
|
53
48
|
end
|
54
|
-
|
49
|
+
run_git_cmd 'push', 'origin', 'HEAD'
|
55
50
|
end
|
56
51
|
|
57
52
|
def feature_branch_name
|
@@ -67,8 +62,8 @@ module Gitx
|
|
67
62
|
# nuke local branch and pull fresh version from remote repo
|
68
63
|
def fetch_remote_branch(target_branch)
|
69
64
|
create_remote_branch(target_branch) unless remote_branch_exists?(target_branch)
|
70
|
-
|
71
|
-
|
65
|
+
run_git_cmd 'fetch', 'origin'
|
66
|
+
run_git_cmd('branch', '--delete', '--force', target_branch) rescue Gitx::Executor::ExecutionError
|
72
67
|
checkout_branch target_branch
|
73
68
|
end
|
74
69
|
|
@@ -86,7 +81,7 @@ module Gitx
|
|
86
81
|
|
87
82
|
def create_remote_branch(target_branch)
|
88
83
|
repo.create_branch(target_branch, config.base_branch)
|
89
|
-
|
84
|
+
run_git_cmd 'push', 'origin', "#{target_branch}:#{target_branch}"
|
90
85
|
end
|
91
86
|
end
|
92
87
|
end
|
@@ -22,11 +22,10 @@ module Gitx
|
|
22
22
|
say last_known_good_tag, :green
|
23
23
|
|
24
24
|
checkout_branch config.base_branch
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
run_cmd "git branch --set-upstream-to origin/#{bad_branch}"
|
25
|
+
run_git_cmd('branch', '--delete', '--force', bad_branch) rescue Gitx::Executor::ExecutionError
|
26
|
+
run_git_cmd('push', 'origin', '--delete', bad_branch) rescue Gitx::Executor::ExecutionError
|
27
|
+
run_git_cmd 'checkout', '-b', bad_branch, last_known_good_tag
|
28
|
+
run_git_cmd 'share'
|
30
29
|
checkout_branch config.base_branch
|
31
30
|
end
|
32
31
|
|
@@ -34,7 +33,7 @@ module Gitx
|
|
34
33
|
|
35
34
|
def migrations_need_to_be_reverted?(bad_branch, last_known_good_tag)
|
36
35
|
return false unless File.exist?('db/migrate')
|
37
|
-
outdated_migrations =
|
36
|
+
outdated_migrations = run_git_cmd('diff', "#{last_known_good_tag}...#{bad_branch}", '--name-only', 'db/migrate').split
|
38
37
|
return false if outdated_migrations.empty?
|
39
38
|
|
40
39
|
say "#{bad_branch} contains migrations that may need to be reverted. Ensure any reversable migrations are reverted on affected databases before nuking.", :red
|
@@ -53,8 +52,8 @@ module Gitx
|
|
53
52
|
end
|
54
53
|
|
55
54
|
def build_tags_for_branch(branch)
|
56
|
-
|
57
|
-
build_tags =
|
55
|
+
run_git_cmd 'fetch', '--tags'
|
56
|
+
build_tags = run_git_cmd('tag', '--list', "build-#{branch}-*").split
|
58
57
|
build_tags.sort
|
59
58
|
end
|
60
59
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'thor'
|
2
2
|
require 'gitx'
|
3
3
|
require 'gitx/cli/base_command'
|
4
|
-
require 'gitx/cli/update_command'
|
5
4
|
require 'gitx/github'
|
6
5
|
|
7
6
|
module Gitx
|
@@ -17,15 +16,15 @@ module Gitx
|
|
17
16
|
branch ||= current_branch.name
|
18
17
|
assert_not_protected_branch!(branch, 'release')
|
19
18
|
checkout_branch(branch)
|
20
|
-
|
19
|
+
run_git_cmd 'update'
|
21
20
|
|
22
21
|
pull_request = find_or_create_pull_request(branch)
|
23
22
|
return unless confirm_branch_status?(branch)
|
24
23
|
|
25
24
|
checkout_branch config.base_branch
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
run_git_cmd 'pull', 'origin', config.base_branch
|
26
|
+
run_git_cmd 'merge', '--no-ff', '--message', "[gitx] Releasing #{branch} to #{config.base_branch} (Pull request ##{pull_request.number})", branch
|
27
|
+
run_git_cmd 'push', 'origin', 'HEAD'
|
29
28
|
|
30
29
|
after_release
|
31
30
|
end
|
@@ -50,7 +50,7 @@ module Gitx
|
|
50
50
|
reject_pull_request(pull_request) if options[:reject]
|
51
51
|
assign_pull_request(pull_request) if options[:assignee]
|
52
52
|
|
53
|
-
run_cmd
|
53
|
+
run_cmd('open', pull_request.html_url) if options[:open]
|
54
54
|
end
|
55
55
|
|
56
56
|
private
|
@@ -7,8 +7,8 @@ module Gitx
|
|
7
7
|
class ShareCommand < BaseCommand
|
8
8
|
desc 'share', 'Share the current branch in the remote repository'
|
9
9
|
def share
|
10
|
-
|
11
|
-
|
10
|
+
run_git_cmd 'push', 'origin', current_branch.name
|
11
|
+
run_git_cmd 'track'
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -7,7 +7,7 @@ module Gitx
|
|
7
7
|
class TrackCommand < BaseCommand
|
8
8
|
desc 'track', 'set the current branch to track the remote branch with the same name'
|
9
9
|
def track
|
10
|
-
|
10
|
+
run_git_cmd 'branch', '--set-upstream-to', "origin/#{current_branch.name}"
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -14,15 +14,15 @@ module Gitx
|
|
14
14
|
|
15
15
|
update_branch(current_branch.name) if remote_branch_exists?(current_branch.name)
|
16
16
|
update_branch(config.base_branch)
|
17
|
-
|
17
|
+
run_git_cmd 'share'
|
18
18
|
end
|
19
19
|
|
20
20
|
private
|
21
21
|
|
22
22
|
def update_branch(branch)
|
23
|
-
|
23
|
+
run_git_cmd 'pull', 'origin', branch
|
24
24
|
rescue
|
25
|
-
raise MergeError, 'Merge
|
25
|
+
raise MergeError, 'Merge conflict occurred. Please fix merge conflict and rerun the command'
|
26
26
|
end
|
27
27
|
|
28
28
|
def remote_branch_exists?(branch)
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'open3'
|
2
|
+
|
3
|
+
module Gitx
|
4
|
+
class Executor
|
5
|
+
ExecutionError = Class.new(StandardError)
|
6
|
+
|
7
|
+
# execute a shell command and raise an error if non-zero exit code is returned
|
8
|
+
# return the string output from the command
|
9
|
+
# block argument is passed all output from the executed thread
|
10
|
+
def execute(*cmd)
|
11
|
+
yield "$ #{cmd.join(' ')}" if block_given?
|
12
|
+
output = ''
|
13
|
+
|
14
|
+
Open3.popen2e(*cmd) do |stdin, stdout_err, wait_thread|
|
15
|
+
while line = stdout_err.gets
|
16
|
+
output << line
|
17
|
+
yield line if block_given?
|
18
|
+
end
|
19
|
+
|
20
|
+
exit_status = wait_thread.value
|
21
|
+
fail ExecutionError, "#{cmd.join(' ')} failed" unless exit_status.success?
|
22
|
+
end
|
23
|
+
output
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/gitx/extensions/thor.rb
CHANGED
@@ -1,27 +1,5 @@
|
|
1
|
-
require 'open3'
|
2
|
-
|
3
1
|
class Thor
|
4
2
|
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(*args)
|
8
|
-
options = args.last.is_a?(Hash) ? args.pop : {}
|
9
|
-
cmd = args
|
10
|
-
say "$ #{cmd.join(' ')}", :yellow
|
11
|
-
output = ''
|
12
|
-
|
13
|
-
Open3.popen2e(*cmd) do |stdin, stdout_err, wait_thr|
|
14
|
-
while line = stdout_err.gets
|
15
|
-
say(line, :yellow) if options[:trace]
|
16
|
-
output << line
|
17
|
-
end
|
18
|
-
|
19
|
-
exit_status = wait_thr.value
|
20
|
-
fail "#{cmd.join(' ')} failed" unless exit_status.success? || options[:allow_failure]
|
21
|
-
end
|
22
|
-
output
|
23
|
-
end
|
24
|
-
|
25
3
|
# launch configured editor to retreive message/string
|
26
4
|
# see http://osdir.com/ml/ruby-talk/2010-06/msg01424.html
|
27
5
|
# see https://gist.github.com/rkumar/456809
|
data/lib/gitx/github.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'octokit'
|
2
2
|
require 'fileutils'
|
3
3
|
require 'yaml'
|
4
|
-
require 'gitx/cli/update_command'
|
5
4
|
|
6
5
|
module Gitx
|
7
6
|
module Github
|
@@ -23,7 +22,7 @@ module Gitx
|
|
23
22
|
pull_request = find_pull_request(branch)
|
24
23
|
pull_request ||= begin
|
25
24
|
checkout_branch(branch)
|
26
|
-
|
25
|
+
run_git_cmd 'update'
|
27
26
|
pull_request = create_pull_request(branch)
|
28
27
|
say 'Created pull request: '
|
29
28
|
say pull_request.html_url, :green
|
@@ -73,7 +72,7 @@ module Gitx
|
|
73
72
|
end
|
74
73
|
|
75
74
|
def pull_request_body(branch)
|
76
|
-
changelog =
|
75
|
+
changelog = run_git_cmd('log', "#{config.base_branch}...#{branch}", '--reverse', '--no-merges', "--pretty=format:'* %B'")
|
77
76
|
description = options[:description]
|
78
77
|
|
79
78
|
description_template = []
|
data/lib/gitx/version.rb
CHANGED
@@ -10,6 +10,7 @@ describe Gitx::Cli::BuildtagCommand do
|
|
10
10
|
}
|
11
11
|
end
|
12
12
|
let(:cli) { described_class.new(args, options, config) }
|
13
|
+
let(:executor) { cli.send(:executor) }
|
13
14
|
let(:branch) { double('fake branch', name: 'feature-branch') }
|
14
15
|
|
15
16
|
before do
|
@@ -40,8 +41,8 @@ describe Gitx::Cli::BuildtagCommand do
|
|
40
41
|
end
|
41
42
|
before do
|
42
43
|
Timecop.freeze(Time.utc(2013, 10, 30, 10, 21, 28)) do
|
43
|
-
expect(
|
44
|
-
expect(
|
44
|
+
expect(executor).to receive(:execute).with('git', 'tag', 'build-master-2013-10-30-10-21-28', '--annotate', '--message', '[gitx] buildtag for master').ordered
|
45
|
+
expect(executor).to receive(:execute).with('git', 'push', 'origin', 'build-master-2013-10-30-10-21-28').ordered
|
45
46
|
cli.buildtag
|
46
47
|
end
|
47
48
|
end
|
@@ -58,8 +59,8 @@ describe Gitx::Cli::BuildtagCommand do
|
|
58
59
|
end
|
59
60
|
before do
|
60
61
|
Timecop.freeze(Time.utc(2013, 10, 30, 10, 21, 28)) do
|
61
|
-
expect(
|
62
|
-
expect(
|
62
|
+
expect(executor).to receive(:execute).with('git', 'tag', 'build-master-2013-10-30-10-21-28', '--annotate', '--message', 'custom git commit message').ordered
|
63
|
+
expect(executor).to receive(:execute).with('git', 'push', 'origin', 'build-master-2013-10-30-10-21-28').ordered
|
63
64
|
cli.buildtag
|
64
65
|
end
|
65
66
|
end
|
@@ -9,8 +9,11 @@ describe Gitx::Cli::CleanupCommand do
|
|
9
9
|
pretend: true
|
10
10
|
}
|
11
11
|
end
|
12
|
-
let(:cli) {
|
12
|
+
let(:cli) { described_class.new(args, options, config) }
|
13
|
+
let(:executor) { cli.send(:executor) }
|
13
14
|
let(:branch) { double('fake branch', name: 'feature-branch') }
|
15
|
+
let(:remote_branches) { 'merged-remote-feature' }
|
16
|
+
let(:local_branches) { 'merged-local-feature' }
|
14
17
|
|
15
18
|
before do
|
16
19
|
allow(cli).to receive(:current_branch).and_return(branch)
|
@@ -20,13 +23,13 @@ describe Gitx::Cli::CleanupCommand do
|
|
20
23
|
before do
|
21
24
|
allow(cli).to receive(:say)
|
22
25
|
|
23
|
-
expect(
|
24
|
-
expect(
|
25
|
-
expect(
|
26
|
-
expect(
|
27
|
-
expect(
|
28
|
-
expect(
|
29
|
-
expect(
|
26
|
+
expect(executor).to receive(:execute).with('git', 'checkout', 'master').ordered
|
27
|
+
expect(executor).to receive(:execute).with('git', 'pull').ordered
|
28
|
+
expect(executor).to receive(:execute).with('git', 'remote', 'prune', 'origin').ordered
|
29
|
+
expect(executor).to receive(:execute).with('git', 'branch', '--remote', '--merged').and_return(remote_branches).ordered
|
30
|
+
expect(executor).to receive(:execute).with('git', 'push', 'origin', '--delete', 'merged-remote-feature').ordered
|
31
|
+
expect(executor).to receive(:execute).with('git', 'branch', '--merged').and_return(local_branches).ordered
|
32
|
+
expect(executor).to receive(:execute).with('git', 'branch', '--delete', 'merged-local-feature').ordered
|
30
33
|
|
31
34
|
cli.cleanup
|
32
35
|
end
|