git-bundle 1.0.16 → 1.0.18
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/Gemfile.lock +1 -1
- data/lib/git_bundle/branch_config.rb +19 -1
- data/lib/git_bundle/commands/checkout.rb +34 -21
- data/lib/git_bundle/commands/generate.rb +1 -1
- data/lib/git_bundle/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d5e435d1dd24f9d955632075556705ba3503475ef4bea749b8c3814c473b6f1
|
4
|
+
data.tar.gz: 452aa1be724f46937ee68975f6813c622470fb50d3d2302cc18c0f239c4916ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fdbd6c5a9c6eb2a414384828439eb249e7692a6987912b00e04f1e037893f2a1724f3c0c572d30cbb5e30d31bfa0d1801e536faea1bda027dfec7430d85fdcc
|
7
|
+
data.tar.gz: 235a9d14af3802d74e22ac5cddda6e62a4baf9e1ed00fb85920c10511a7a6d747ba5b8470984e554fa659090b1e3ffa439ecc04cb84611044c2f962f45443d10
|
data/Gemfile.lock
CHANGED
@@ -18,6 +18,24 @@ module GitBundle
|
|
18
18
|
@current = read
|
19
19
|
end
|
20
20
|
|
21
|
+
def remote(repo_name)
|
22
|
+
source = current[repo_name]
|
23
|
+
if source.include?(' ')
|
24
|
+
source.split(' ').first
|
25
|
+
else
|
26
|
+
nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def branch(repo_name)
|
31
|
+
source = current[repo_name]
|
32
|
+
if source&.include?(' ')
|
33
|
+
source.split(' ').last
|
34
|
+
else
|
35
|
+
source
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
21
39
|
def read
|
22
40
|
File.exists?(path) ? YAML.load_file(path) || {} : nil
|
23
41
|
end
|
@@ -28,7 +46,7 @@ module GitBundle
|
|
28
46
|
|
29
47
|
def save
|
30
48
|
if changed?
|
31
|
-
File.open(path, 'w') {|file| file.write(current.to_yaml.lines[1..-1].join)}
|
49
|
+
File.open(path, 'w') { |file| file.write(current.to_yaml.lines[1..-1].join) }
|
32
50
|
if File.exists?(path)
|
33
51
|
puts "\t#{colorize('update', 34, bold: true)}\t#{filename}"
|
34
52
|
else
|
@@ -10,55 +10,68 @@ module GitBundle
|
|
10
10
|
|
11
11
|
def invoke
|
12
12
|
@project.load_dependant_repositories
|
13
|
+
remaining_args = @args.dup
|
14
|
+
flag = remaining_args.first&.chars&.first == "-" ? remaining_args.shift : nil
|
15
|
+
branch = remaining_args.shift
|
13
16
|
|
14
|
-
if
|
15
|
-
|
17
|
+
if remaining_args.any? || (flag && branch.nil?)
|
18
|
+
puts_error "Invalid arguments for checkout. Usage: \n\tgitb checkout\n\tgitb checkout <branch>\n\tgitb checkout <remote/branch>\n\tgitb checkout -b <new branch>\n\tgitb checkout -a <force branch all repositories>"
|
19
|
+
return
|
20
|
+
end
|
16
21
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
elsif @args.size == 2 && @args.first == '-b'
|
22
|
-
if checkout(@project.main_repository, @args.last, create_new: true, force: true)
|
23
|
-
@project.dependant_repositories.each {|r| checkout(r, @args.last, create_new: true)}
|
22
|
+
case
|
23
|
+
when flag == "-a" || flag == "--all"
|
24
|
+
if checkout(@project.main_repository, branch)
|
25
|
+
@project.dependant_repositories.each { |r| checkout(r, branch) }
|
24
26
|
end
|
25
27
|
@project.branch_config.save if @project.branch_config.changed?
|
26
|
-
|
27
|
-
if checkout(@project.main_repository,
|
28
|
-
@project.dependant_repositories.each {|r| checkout(r,
|
28
|
+
when flag == "-b"
|
29
|
+
if checkout(@project.main_repository, branch, create_new: true, force: true)
|
30
|
+
@project.dependant_repositories.each { |r| checkout(r, branch, create_new: true) }
|
29
31
|
end
|
30
32
|
@project.branch_config.save if @project.branch_config.changed?
|
33
|
+
when branch.nil?
|
34
|
+
checkout_parallel(@project.dependant_repositories, fallback_branch: @project.main_repository.branch)
|
31
35
|
else
|
32
|
-
|
36
|
+
if checkout(@project.main_repository, branch)
|
37
|
+
checkout_parallel(@project.dependant_repositories, fallback_branch: branch)
|
38
|
+
end
|
33
39
|
end
|
34
40
|
end
|
35
41
|
|
36
42
|
def checkout(repo, branch, create_new: false, force: false)
|
43
|
+
args = ['checkout']
|
37
44
|
if create_new
|
38
45
|
unless force
|
39
46
|
puts_repo_heading(repo)
|
40
47
|
puts_prompt("Create #{branch}? (Y/N)")
|
41
48
|
return unless STDIN.getch.upcase == 'Y'
|
42
49
|
end
|
43
|
-
args
|
44
|
-
else
|
45
|
-
args = ['checkout', branch]
|
50
|
+
args << '-b'
|
46
51
|
end
|
52
|
+
args << branch
|
47
53
|
|
48
54
|
output = repo.execute_git(args, color: true)
|
49
55
|
success = $?.exitstatus == 0
|
50
56
|
repo.refresh_branch
|
51
57
|
puts_repo_heading(repo) unless create_new && !force
|
52
|
-
success
|
53
|
-
|
54
|
-
|
58
|
+
if success && !repo.main && create_new && @project.branch_config.current
|
59
|
+
old_remote = @project.branch_config.remote(repo.name)
|
60
|
+
if old_remote
|
61
|
+
@project.branch_config.current[repo.name] = "#{old_remote} #{branch}"
|
62
|
+
else
|
63
|
+
@project.branch_config.current[repo.name] = branch
|
64
|
+
end
|
65
|
+
puts(output)
|
66
|
+
else
|
67
|
+
puts_error(output)
|
55
68
|
end
|
56
69
|
success
|
57
70
|
end
|
58
71
|
|
59
|
-
def checkout_parallel(repositories, fallback_branch)
|
72
|
+
def checkout_parallel(repositories, fallback_branch: nil)
|
60
73
|
parallel(repositories) do |repo|
|
61
|
-
output = repo.execute_git(['checkout', @project.branch_config.
|
74
|
+
output = repo.execute_git(['checkout', @project.branch_config.branch(repo.name) || fallback_branch], color: true)
|
62
75
|
repo.refresh_branch
|
63
76
|
ExecutionResult.new($?.exitstatus != 0, output)
|
64
77
|
end
|
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.18
|
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: 2022-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|