git-bundle 1.0.10 → 1.0.11
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/lib/git_bundle.rb +2 -0
- data/lib/git_bundle/cli.rb +2 -0
- data/lib/git_bundle/commands/checkout.rb +78 -0
- data/lib/git_bundle/repository.rb +3 -3
- data/lib/git_bundle/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 969518eba015e3e24e4c1a3a99235553eebd7a6df95aac38eede235021a95210
|
4
|
+
data.tar.gz: aa3e87047bbda8e7ce7b7c44f74b0def4fbf1c3c34a9eedac0a15716584ff114
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87167ce9f08edd4f318fa392b8c4dcec4ce24bc2f5368fb71cf77e5c405030b82dbfac1550c325b529b7a62c8913c3b643c19ee2bc5432348da7fd9d5cdbd1df
|
7
|
+
data.tar.gz: e8bfec3b2f616be96f6cb4758711db8f82a7bde511a10c5d2f52ed314e1e01e47938f248bc655662678ba8859af863e36dd6a25105ec6815b15cc4287ced17de
|
data/lib/git_bundle.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'bundler'
|
2
|
+
require 'yaml'
|
2
3
|
require 'git_bundle/version'
|
3
4
|
require 'git_bundle/console'
|
4
5
|
require 'git_bundle/shell'
|
@@ -7,4 +8,5 @@ require 'git_bundle/repository'
|
|
7
8
|
require 'git_bundle/project'
|
8
9
|
require 'git_bundle/commands/generic'
|
9
10
|
require 'git_bundle/commands/push'
|
11
|
+
require 'git_bundle/commands/checkout'
|
10
12
|
require 'git_bundle/commands/version'
|
data/lib/git_bundle/cli.rb
CHANGED
@@ -13,6 +13,8 @@ module GitBundle
|
|
13
13
|
puts `git #{args.join(' ')}`.gsub('git', 'gitb')
|
14
14
|
when 'push'
|
15
15
|
GitBundle::Commands::Push.new(@project, args[1..-1]).invoke
|
16
|
+
when 'checkout'
|
17
|
+
GitBundle::Commands::Checkout.new(@project, args[1..-1]).invoke
|
16
18
|
when '--version'
|
17
19
|
GitBundle::Commands::Version.new.invoke
|
18
20
|
else
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module GitBundle
|
2
|
+
module Commands
|
3
|
+
class Checkout
|
4
|
+
BRANCH_CONFIG_FILE = '.gitb.yml'
|
5
|
+
include GitBundle::Console
|
6
|
+
|
7
|
+
def initialize(project, args)
|
8
|
+
@project = project
|
9
|
+
@args = args
|
10
|
+
end
|
11
|
+
|
12
|
+
def invoke
|
13
|
+
@project.load_dependant_repositories
|
14
|
+
|
15
|
+
if @args.empty?
|
16
|
+
checkout_parallel(@project.dependant_repositories, @project.main_repository.branch)
|
17
|
+
|
18
|
+
elsif @args.size == 1
|
19
|
+
if checkout(@project.main_repository, @args.first)
|
20
|
+
checkout_parallel(@project.dependant_repositories, @args.first)
|
21
|
+
end
|
22
|
+
|
23
|
+
elsif @args.size == 2 && @args.first == '-b'
|
24
|
+
if checkout(@project.main_repository, @args.last, create_new: true, force: true)
|
25
|
+
@project.dependant_repositories.each {|r| checkout(r, @args.last, create_new: true)}
|
26
|
+
end
|
27
|
+
else
|
28
|
+
puts_error "Invalid arguments for checkout. Usage: \n\tgitb checkout\n\tgitb checkout <branch>\n\tgitb checkout -b <new_branch>"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def checkout(repo, branch, create_new: false, force: false)
|
33
|
+
if create_new
|
34
|
+
unless force
|
35
|
+
puts_repo_heading(repo)
|
36
|
+
puts_prompt("Create #{branch}? (Y/N)")
|
37
|
+
return unless STDIN.getch.upcase == 'Y'
|
38
|
+
end
|
39
|
+
args = ['checkout', '-b', branch]
|
40
|
+
else
|
41
|
+
args = ['checkout', branch]
|
42
|
+
end
|
43
|
+
|
44
|
+
output = repo.execute_git(args, color: true)
|
45
|
+
success = $?.exitstatus == 0
|
46
|
+
repo.refresh_branch
|
47
|
+
puts_repo_heading(repo) unless create_new && !force
|
48
|
+
success ? puts(output) : puts_error(output)
|
49
|
+
if create_new && success && branch_config
|
50
|
+
branch_config[repo.name] = branch
|
51
|
+
write_branch_config
|
52
|
+
end
|
53
|
+
success
|
54
|
+
end
|
55
|
+
|
56
|
+
def checkout_parallel(repositories, fallback_branch)
|
57
|
+
parallel(repositories) do |repo|
|
58
|
+
output = repo.execute_git(['checkout', branch_config[repo.name] || fallback_branch], color: true)
|
59
|
+
repo.refresh_branch
|
60
|
+
ExecutionResult.new($?.exitstatus != 0, output)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def branch_config
|
65
|
+
return @branch_config if defined?(@branch_config)
|
66
|
+
@branch_config ||= File.exists?(config_file) ? YAML.load_file(config_file) || {} : nil
|
67
|
+
end
|
68
|
+
|
69
|
+
def config_file
|
70
|
+
File.join(Dir.pwd, BRANCH_CONFIG_FILE)
|
71
|
+
end
|
72
|
+
|
73
|
+
def write_branch_config
|
74
|
+
File.open(File.join(Dir.pwd, BRANCH_CONFIG_FILE), 'w') {|file| file.write(branch_config.to_yaml.lines[1..-1].join)}
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -20,13 +20,13 @@ module GitBundle
|
|
20
20
|
@name = name
|
21
21
|
@path = path
|
22
22
|
@main = main_repository
|
23
|
-
@branch = fetch_branch
|
24
23
|
@locked_branch = locked_branch
|
25
24
|
@locked_revision = locked_revision
|
25
|
+
refresh_branch
|
26
26
|
end
|
27
27
|
|
28
|
-
def
|
29
|
-
execute_git('rev-parse', '--abbrev-ref', 'HEAD').chomp
|
28
|
+
def refresh_branch
|
29
|
+
@branch = execute_git('rev-parse', '--abbrev-ref', 'HEAD').chomp
|
30
30
|
end
|
31
31
|
|
32
32
|
def locked_branch
|
data/lib/git_bundle/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-bundle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pierre Pretorius
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -44,6 +44,7 @@ files:
|
|
44
44
|
- git-bundle.gemspec
|
45
45
|
- lib/git_bundle.rb
|
46
46
|
- lib/git_bundle/cli.rb
|
47
|
+
- lib/git_bundle/commands/checkout.rb
|
47
48
|
- lib/git_bundle/commands/generic.rb
|
48
49
|
- lib/git_bundle/commands/push.rb
|
49
50
|
- lib/git_bundle/commands/version.rb
|