rebase_pusher 0.1.0 → 0.1.3
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/bin/rebase_push +5 -0
- data/lib/rebase_pusher/version.rb +1 -1
- data/lib/rebase_pusher.rb +13 -9
- 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: c227c7874dd6e4cf6fcab7351ed5090ca1736e6f6ef4d1f1f4e21fe6e655c74e
|
4
|
+
data.tar.gz: 8ae3f18aa6ead9e2b533f5433d8b0dd1707631b3b4ab18486625facf78fcfd6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71049930e742049c27b7f087e6db0009865018942817849740d2286691c63bd7a2052977303fd24c43a30c2cd68a06c87f5aeef467b55dddd2d4310b77a71ea4
|
7
|
+
data.tar.gz: 27f8adc215aa56d3de8e9739ca9e868017a6c5f74e8c1b2a6f2458887953ce4b83b52cf2be03de8535dac168d57958141b3fc99a6c0e6707f2db6f80824452ed
|
data/bin/rebase_push
CHANGED
@@ -15,6 +15,7 @@ OptionParser.new do |opts|
|
|
15
15
|
|
16
16
|
Example:
|
17
17
|
rebase_push -t reset
|
18
|
+
rebase_push -t reset --ignore branch1,branch2,branch3
|
18
19
|
rebase_push -t rebase
|
19
20
|
rebase_push -t force_push # this is slow, calm down
|
20
21
|
rebase_push -t reset && rebase_push -t rebase
|
@@ -34,6 +35,10 @@ OptionParser.new do |opts|
|
|
34
35
|
opts.on("-v", "--verbose", "Run verbosely") do |v|
|
35
36
|
options[:verbose] = v
|
36
37
|
end
|
38
|
+
|
39
|
+
opts.on("--ignore branch1,branch2", Array, "Specify ignored branches") do |branches|
|
40
|
+
options[:ignored_branches] = branches.uniq
|
41
|
+
end
|
37
42
|
end.parse!
|
38
43
|
|
39
44
|
RebasePusher.new(options).run
|
data/lib/rebase_pusher.rb
CHANGED
@@ -23,12 +23,12 @@ class RebasePusher
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def run
|
26
|
-
io.puts "skipped branches: #{branches -
|
26
|
+
io.puts "skipped branches: #{branches - to_operate_branches}"
|
27
27
|
sh("git checkout --quiet #{default_branch}")
|
28
28
|
|
29
29
|
case options[:operation_type]
|
30
30
|
when :rebase
|
31
|
-
|
31
|
+
to_operate_branches.each do |branch|
|
32
32
|
io.print "." if !options[:verbose]
|
33
33
|
sh("git rebase --quiet #{default_branch} #{branch}")
|
34
34
|
end
|
@@ -36,7 +36,7 @@ class RebasePusher
|
|
36
36
|
io.puts if !options[:verbose]
|
37
37
|
io.puts "all my branches are rebased"
|
38
38
|
when :reset
|
39
|
-
|
39
|
+
to_operate_branches.each do |branch|
|
40
40
|
io.print "." if !options[:verbose]
|
41
41
|
sh("git branch --force #{branch} #{branch}@{u}")
|
42
42
|
end
|
@@ -46,7 +46,7 @@ class RebasePusher
|
|
46
46
|
when :force_push
|
47
47
|
# https://git-scm.com/docs/git-push
|
48
48
|
# refspec: <src>:<dst>
|
49
|
-
|
49
|
+
to_operate_branches.each do |branch|
|
50
50
|
io.print "." if !options[:verbose]
|
51
51
|
sh("git push origin --quiet --force-with-lease --force-if-includes #{branch}:#{branch}")
|
52
52
|
end
|
@@ -56,22 +56,26 @@ class RebasePusher
|
|
56
56
|
else
|
57
57
|
raise "NOT SUPPORTTED"
|
58
58
|
end
|
59
|
-
|
59
|
+
ensure
|
60
60
|
sh("git checkout --quiet #{original_branch}")
|
61
61
|
end
|
62
62
|
|
63
63
|
private
|
64
64
|
|
65
|
-
|
66
|
-
|
67
|
-
@my_branches ||= branches.select do |branch|
|
65
|
+
def to_operate_branches
|
66
|
+
@to_operate_branches ||= branches.select do |branch|
|
68
67
|
merge_base_commitid = sh("git merge-base #{default_branch} #{branch}").chomp
|
68
|
+
# Make sure I never touch other people's branch
|
69
69
|
author_emails = sh("git log --format='%ae' #{merge_base_commitid}..#{branch}").split("\n").uniq
|
70
70
|
|
71
|
-
!author_emails.empty? && author_emails.all? { |email| email == my_email }
|
71
|
+
!ignored_branches.include?(branch) && !author_emails.empty? && author_emails.all? { |email| email == my_email }
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
+
def ignored_branches
|
76
|
+
options[:ignored_branches] || []
|
77
|
+
end
|
78
|
+
|
75
79
|
def default_branch
|
76
80
|
@default_branch ||= sh("git rev-parse --abbrev-ref origin/HEAD").chomp
|
77
81
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rebase_pusher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lijunwei
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: git rebase and push for all my branches
|
14
14
|
email:
|