git_commands 3.2.4 → 3.2.5

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
  SHA1:
3
- metadata.gz: 04d715f8ac8ef6b5bf01a245a2133b7d519a299a
4
- data.tar.gz: 25aa0aa99a3ce31fa2b451eadc5a78f7abe3f77f
3
+ metadata.gz: cdad6f742ea09e2b50d560714ee7a74b7848ffc5
4
+ data.tar.gz: 88697a5add19a72d6cbb0602e1ee423aa6bcbb6b
5
5
  SHA512:
6
- metadata.gz: 52d78c66d5ad58c572b4494d351245ec15e693b52bbc7d524bf5f1e2af3e6530fda2aac73a8c95af637421d1d7f872c16b6e33ffe27739b749c312a125dd191f
7
- data.tar.gz: 55fbd08440747822e4480eec3ac4b375fc93ad0e98a20ad865ed26247a89e87d12b5c538c3d4df1b5842bf6e09f6c4598ee5bf0146ff3484785c9526d595cca0
6
+ metadata.gz: 90a1dbe956bb86468132c4993d2443ead432a6998dcaf6f1e64f320971a97bf466bbdee99dc81ae7b854f40782299bab8ad357bc5644adfceca07fe20db4483f
7
+ data.tar.gz: 38774eda256e02d2e4ba318de4e031862392ab9ecbb785121b0525dd8df05331627e42ba68e02ebeaf51f5f8da9f9156a389fb43aacc2215266f1ae6f930fdf3
@@ -59,8 +59,9 @@ module GitCommands
59
59
  @name == MASTER
60
60
  end
61
61
 
62
- private def exists?
63
- `git rev-parse --verify origin/#{@name} 2> /dev/null`.match(/^[0-9a-z]+/)
62
+ def exists?(remote = true)
63
+ origin = ORIGIN if remote
64
+ `git rev-parse --verify #{origin}#{@name} 2> /dev/null`.match(/^[0-9a-z]+/)
64
65
  end
65
66
  end
66
67
  end
@@ -16,7 +16,6 @@ module GitCommands
16
16
  def initialize(repo:, branches:, repo_klass: Repository, branch_klass: Branch, out: STDOUT)
17
17
  @out = out
18
18
  @repo = repo_klass.new(repo)
19
- @conflictual = []
20
19
  Dir.chdir(@repo) do
21
20
  @branches = branch_klass.factory(branches)
22
21
  @timestamp = Time.new.strftime("%Y-%m-%d")
@@ -26,12 +25,10 @@ module GitCommands
26
25
 
27
26
  def purge
28
27
  enter_repo do
29
- @branches.each do |branch|
30
- warning("Removing branch: #{branch}")
31
- confirm("Remove local branch") do
32
- `git branch -D #{branch}`
33
- end
34
- confirm("Remove remote branch") do
28
+ confirm("Proceed removing these branches") do
29
+ @branches.each do |branch|
30
+ warning("Removing branch: #{branch}")
31
+ `git branch -D #{branch}` if branch.exists?(false)
35
32
  `git push origin :#{branch}`
36
33
  end
37
34
  end
@@ -45,13 +42,12 @@ module GitCommands
45
42
  warning("Rebasing branch: #{branch}")
46
43
  `git checkout #{branch}`
47
44
  `git pull origin #{branch}`
48
- @conflictual << branch && next unless rebase_with_master
45
+ next unless rebase_with_master
49
46
  `git push -f origin #{branch}`
50
47
  `git checkout #{Branch::MASTER}`
51
48
  `git branch -D #{branch}`
52
- success "Rebased successfully!"
49
+ success("Rebased successfully!")
53
50
  end
54
- delete_conflictual
55
51
  end
56
52
  end
57
53
  end
@@ -65,16 +61,14 @@ module GitCommands
65
61
  @branches.each do |branch|
66
62
  warning("Merging branch: #{branch}")
67
63
  `git checkout -b #{temp} origin/#{branch} --no-track`
68
- @conflictual << branch && next unless rebase_with_master
64
+ exit unless rebase_with_master
69
65
  `git rebase #{aggregate}`
70
66
  `git checkout #{aggregate}`
71
67
  `git merge #{temp}`
72
- `git branch -d #{temp}`
68
+ `git branch -D #{temp}`
73
69
  end
74
- `git checkout #{Branch::MASTER}`
75
70
  end
76
- delete_conflictual
77
- success "#{aggregate} branch created"
71
+ success("#{aggregate} branch created")
78
72
  end
79
73
  end
80
74
 
@@ -82,7 +76,7 @@ module GitCommands
82
76
  fail GitError, "No branches loaded!" if @branches.empty?
83
77
  size = @branches.to_a.size
84
78
  plural = size > 1 ? "es" : ""
85
- success "Successfully loaded #{size} branch#{plural}:"
79
+ success("Successfully loaded #{size} branch#{plural}:")
86
80
  @out.puts @branches.each_with_index.map { |branch, i| "#{(i+1).to_s.rjust(2, "0")}. #{branch}" } + [""]
87
81
  end
88
82
 
@@ -98,14 +92,6 @@ module GitCommands
98
92
  error("Got conflicts, aborting rebase!")
99
93
  end
100
94
 
101
- private def delete_conflictual
102
- return if @conflictual.empty?
103
- `git checkout #{Branch::MASTER}`
104
- @conflictual.each do |branch|
105
- `git branch -D #{branch}`
106
- end
107
- end
108
-
109
95
  private def enter_repo
110
96
  Dir.chdir(@repo) do
111
97
  pull_master
@@ -12,7 +12,7 @@ module GitCommands
12
12
  end
13
13
 
14
14
  def warning(message)
15
- out.puts "\n#{message}...".yellow
15
+ out.puts "\n#{message}".yellow
16
16
  end
17
17
 
18
18
  def success(message)
@@ -1,3 +1,3 @@
1
1
  module GitCommands
2
- VERSION = "3.2.4"
2
+ VERSION = "3.2.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_commands
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.4
4
+ version: 3.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - costajob