git-bundle 1.0.15 → 1.0.16
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/commands/generate.rb +9 -1
- data/lib/git_bundle/commands/push.rb +15 -6
- data/lib/git_bundle/repository.rb +12 -5
- data/lib/git_bundle/shell.rb +3 -2
- data/lib/git_bundle/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3695e18c4ce00b28d229d3a0c471066be6fabb1117b2a363f2fa447766b8c4a
|
4
|
+
data.tar.gz: 27ef1522b91ef11574b109096a36fb62f41990630de84d9b31c97110e1da2523
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4322df4990c97e2fd8f6b41fda7471ace527a89c1f4aab6868e679493a88bc09df39a32bed5d3a5045b4b912497b6a3343ca796b1751582cb41ac8e31c60f358
|
7
|
+
data.tar.gz: d6b2258ae386d3b39bcd9757e9c5f2dc3e902a6b5e28152f027d6050180053dc338915f550baa7ba5a6855e0698e7db5593bc0359ec071183a4f2d8369318aa7
|
data/Gemfile.lock
CHANGED
@@ -10,9 +10,17 @@ module GitBundle
|
|
10
10
|
|
11
11
|
def invoke
|
12
12
|
@project.load_dependant_repositories
|
13
|
-
@project.dependant_repositories.each {|
|
13
|
+
@project.dependant_repositories.each { |repo| @project.branch_config.current[repo.name] = remote_branch_reference(repo) }
|
14
14
|
@project.branch_config.save
|
15
15
|
end
|
16
|
+
|
17
|
+
def remote_branch_reference(repository)
|
18
|
+
if repository.remote
|
19
|
+
"#{repository.remote}/#{repository.branch}"
|
20
|
+
else
|
21
|
+
repository.branch
|
22
|
+
end
|
23
|
+
end
|
16
24
|
end
|
17
25
|
end
|
18
26
|
end
|
@@ -11,7 +11,12 @@ module GitBundle
|
|
11
11
|
|
12
12
|
def invoke
|
13
13
|
@project.load_dependant_repositories
|
14
|
-
|
14
|
+
remote = @args.first || @project.main_repository.remote
|
15
|
+
unless remote
|
16
|
+
puts_error "New branch '#{@project.main_repository.branch}' is not tracking a remote branch. Specify which remote to push to, example:\n\tgitb push origin"
|
17
|
+
return false
|
18
|
+
end
|
19
|
+
return false unless prompt_confirm(remote)
|
15
20
|
|
16
21
|
main_repository = @project.main_repository
|
17
22
|
|
@@ -22,7 +27,7 @@ module GitBundle
|
|
22
27
|
end.join(', ')
|
23
28
|
|
24
29
|
stale_commits_description = ''
|
25
|
-
stale_repos.select
|
30
|
+
stale_repos.select { |r| r.upstream_branch_exists? }.each do |repo|
|
26
31
|
stale_commits_description << "== #{repo.name} ==\n"
|
27
32
|
stale_commits_description << repo.stale_commits
|
28
33
|
stale_commits_description << "\n\n"
|
@@ -51,7 +56,11 @@ module GitBundle
|
|
51
56
|
@project.dependant_repositories.select { |repo| repo.commits_not_pushed? }.each do |repo|
|
52
57
|
puts_repo_heading(repo)
|
53
58
|
|
54
|
-
create_upstream =
|
59
|
+
create_upstream = repo.upstream_branch_exists? ? nil : remote
|
60
|
+
if create_upstream && !repo.remote_exists?(create_upstream)
|
61
|
+
puts_error "Invalid remote: #{remote}"
|
62
|
+
return false
|
63
|
+
end
|
55
64
|
unless repo.push(@args, create_upstream: create_upstream)
|
56
65
|
puts_error "Failed to push changes of #{repo.name}. Try pulling the latest changes or resolve conflicts first."
|
57
66
|
return false
|
@@ -59,7 +68,7 @@ module GitBundle
|
|
59
68
|
end
|
60
69
|
|
61
70
|
puts_repo_heading(main_repository)
|
62
|
-
create_upstream =
|
71
|
+
create_upstream = main_repository.upstream_branch_exists? ? nil : remote
|
63
72
|
unless main_repository.push(@args, create_upstream: create_upstream)
|
64
73
|
puts_error "Failed to push changes of #{main_repository.name}. Try pulling the latest changes or resolve conflicts first."
|
65
74
|
end
|
@@ -67,7 +76,7 @@ module GitBundle
|
|
67
76
|
|
68
77
|
private
|
69
78
|
|
70
|
-
def prompt_confirm
|
79
|
+
def prompt_confirm(remote)
|
71
80
|
if @project.main_repository.file_changed?('Gemfile')
|
72
81
|
puts_error 'Your Gemfile has uncommitted changes. Commit them first before pushing.'
|
73
82
|
return false
|
@@ -90,7 +99,7 @@ module GitBundle
|
|
90
99
|
end
|
91
100
|
else
|
92
101
|
upstream_branches_missing << repo.name
|
93
|
-
puts
|
102
|
+
puts "Remote branch #{remote}/#{repo.branch} does not exist yet."
|
94
103
|
end
|
95
104
|
end
|
96
105
|
|
@@ -5,6 +5,7 @@ module GitBundle
|
|
5
5
|
attr_reader :name,
|
6
6
|
:path,
|
7
7
|
:main,
|
8
|
+
:remote,
|
8
9
|
:branch,
|
9
10
|
:locked_branch
|
10
11
|
|
@@ -26,6 +27,7 @@ module GitBundle
|
|
26
27
|
end
|
27
28
|
|
28
29
|
def refresh_branch
|
30
|
+
@remote = execute(*git_command('rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{u}'), silence_err: true).split('/').first
|
29
31
|
@branch = execute_git('rev-parse', '--abbrev-ref', 'HEAD').chomp
|
30
32
|
end
|
31
33
|
|
@@ -50,8 +52,12 @@ module GitBundle
|
|
50
52
|
$?.exitstatus == 0
|
51
53
|
end
|
52
54
|
|
55
|
+
def remote_exists?(remote_name)
|
56
|
+
execute_git('remote').split("\n").include?(remote_name)
|
57
|
+
end
|
58
|
+
|
53
59
|
def upstream_branch_exists?
|
54
|
-
reference_exists?("
|
60
|
+
reference_exists?("#{remote}/#{branch}")
|
55
61
|
end
|
56
62
|
|
57
63
|
def stale_commits
|
@@ -68,15 +74,16 @@ module GitBundle
|
|
68
74
|
end
|
69
75
|
|
70
76
|
def commits_not_pushed
|
71
|
-
execute_git('rev-list', '--pretty=oneline', '--abbrev-commit', "
|
77
|
+
execute_git('rev-list', '--pretty=oneline', '--abbrev-commit', "#{remote}/#{branch}..#{branch}")
|
72
78
|
end
|
73
79
|
|
74
80
|
def commits_not_pushed_count
|
75
|
-
execute_git('rev-list', '--pretty=oneline', '--abbrev-commit', '--count', "
|
81
|
+
execute_git('rev-list', '--pretty=oneline', '--abbrev-commit', '--count', "#{remote}/#{branch}..#{branch}").to_i
|
76
82
|
end
|
77
83
|
|
78
|
-
|
79
|
-
|
84
|
+
# Example: push([], create_upstream: 'origin')
|
85
|
+
def push(args, create_upstream: nil)
|
86
|
+
args = args.dup + ['--set-upstream', create_upstream, branch] if create_upstream
|
80
87
|
execute_git_output('push', args)
|
81
88
|
$?.exitstatus == 0 || (create_upstream && $?.exitstatus == 128)
|
82
89
|
end
|
data/lib/git_bundle/shell.rb
CHANGED
@@ -17,11 +17,12 @@ module GitBundle
|
|
17
17
|
execute_pipe(*args).each_line { |line| puts line.chomp }
|
18
18
|
end
|
19
19
|
|
20
|
-
def execute(*args)
|
20
|
+
def execute(*args, silence_err: false)
|
21
21
|
puts args.map { |arg| "'#{arg}'" }.join(' ') if ENV['DEBUG'] == 'true'
|
22
22
|
|
23
23
|
pipe_out, pipe_in = IO.pipe
|
24
|
-
|
24
|
+
pipe_err_in = silence_err ? File::NULL : pipe_in
|
25
|
+
system *args, out: pipe_in, err: pipe_err_in
|
25
26
|
pipe_in.close
|
26
27
|
pipe_out.read
|
27
28
|
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.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pierre Pretorius
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -74,8 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
requirements: []
|
77
|
-
|
78
|
-
rubygems_version: 2.7.6
|
77
|
+
rubygems_version: 3.1.4
|
79
78
|
signing_key:
|
80
79
|
specification_version: 4
|
81
80
|
summary: Simplifies working with gems from git repositories in combination with local
|