rebase_pusher 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 210c9f95029d1cae3b877543d0ff198a4265c821be7259f5408f58a4418448e6
4
- data.tar.gz: 8c7f2eb6e24a355cdb253847085850002e825788b3452abe4ad6a05773b47943
3
+ metadata.gz: ea6b60854fd639a3a3568a751ed96b6e8dbc60990af06c897352a0945d930ec5
4
+ data.tar.gz: dabea95fa123961a2303c5843a4772251a7abd0e5f63051459ed781693a0933a
5
5
  SHA512:
6
- metadata.gz: e0923d87a648c7fd793bc13d8156248ae2f025f02f1e016e06aa83c8253020711ed25bff2f491612342698215a1eff1d9352000a163ec13afebe6636e159353e
7
- data.tar.gz: 1c1a9cfb77237650ff34a277b967a7bb353c868604f86c42d6e35a8f851e27a3226620d65b6ab668594677120b00ebbfcefbf5f5f0b4658c274069cacb2452dd
6
+ metadata.gz: ca2fbba0884864ea4904621f896a0a85506fa65a292934bc3087aea23fb342c4dc6d56620dd0e1bce1a42f68fb174ea216ca5a6243372536b367d03ea97a1f8f
7
+ data.tar.gz: 20bc3a2fe1848e6fb6374585116410bf603e67528517d1413e2bc81c58e3f329c40dbfbc5e1d470d14a282e742d25d51f92127ec984a084a3954fc54a9486724
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class RebasePusher
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
  end
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 - my_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
- my_branches.each do |branch|
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
- my_branches.each do |branch|
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
- my_branches.each do |branch|
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
- # Ensure I never touch other people's branch
66
- def my_branches
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?(branch) && !author_emails.empty? && author_emails.all? { |email| email == my_email }
72
72
  end
73
73
  end
74
74
 
75
+ def ignored_branches?(branch)
76
+ options[:ignored_branches].include?(branch)
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.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - lijunwei
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-27 00:00:00.000000000 Z
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: