branch_cleaner 0.1.0 → 0.2.0
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/lib/branch_cleaner.rb +29 -32
- metadata +6 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 01fbd5af8345011ce7b8810cf3391b009cae8acb
|
|
4
|
+
data.tar.gz: a7049c74a6afb08385ade65213190b6c8ce2652f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2dcb9df50ea2e37d70a64761706114e19df7884ce97653bec939d99e8776f732d93e573dafc24b0232c8a6ec4d86e9f9c00a9ef9fd75dde8fb12fe123571c95d
|
|
7
|
+
data.tar.gz: 3c8ecfb2f8620d9fef4be72fb76886f274da1af18ee16a0bdadc7abe72a162a52a503e37f1b0b3c42d03bc1059400d284d15112e7238515db2694a0755822bec
|
data/lib/branch_cleaner.rb
CHANGED
|
@@ -1,48 +1,45 @@
|
|
|
1
1
|
require 'set'
|
|
2
2
|
|
|
3
3
|
class BranchCleaner
|
|
4
|
+
def self.get_current_directory()
|
|
5
|
+
`pwd`
|
|
6
|
+
end
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
def self.get_repository_root()
|
|
9
|
+
`git rev-parse --show-toplevel`.strip
|
|
10
|
+
end
|
|
6
11
|
|
|
7
12
|
def self.get_branches()
|
|
8
|
-
|
|
13
|
+
`git branch`.split("\n").map {|b| b.strip }
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.get_branches_to_keep()
|
|
17
|
+
file = get_repository_root() + "/.branches_to_keep"
|
|
18
|
+
keepers = Set.new ["master"]
|
|
19
|
+
if File.exist?(file)
|
|
20
|
+
File.readlines(file).each do |line|
|
|
21
|
+
keepers.add(line.strip)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
return keepers
|
|
9
25
|
end
|
|
10
26
|
|
|
11
27
|
def self.clean()
|
|
28
|
+
repo_root = get_repository_root() ; result = $?.success?
|
|
29
|
+
if !result
|
|
30
|
+
abort("Exiting, not in a git repository")
|
|
31
|
+
end
|
|
12
32
|
branches = get_branches()
|
|
13
|
-
branches_to_keep =
|
|
33
|
+
branches_to_keep = get_branches_to_keep()
|
|
14
34
|
for branch in branches do
|
|
15
|
-
|
|
16
|
-
if
|
|
17
|
-
puts "Skipping branch " +
|
|
35
|
+
branch_name = branch.gsub(/^\*?\s*/, '')
|
|
36
|
+
if branches_to_keep.include?(branch_name)
|
|
37
|
+
puts "Skipping branch " + branch_name
|
|
38
|
+
elsif branch.start_with?('*')
|
|
39
|
+
puts "Skipping active branch " + branch_name
|
|
18
40
|
else
|
|
19
|
-
system("git branch -d " +
|
|
41
|
+
system("git branch -d " + branch_name)
|
|
20
42
|
end
|
|
21
43
|
end
|
|
22
44
|
end
|
|
23
45
|
end
|
|
24
|
-
|
|
25
|
-
# def get_branches_to_keep()
|
|
26
|
-
# branches_to_keep = Set.new ["master"]
|
|
27
|
-
# File.open(KEEP_BRANCHES_PATH, "r") do |f|
|
|
28
|
-
# f.each_line do |line|
|
|
29
|
-
# branches_to_keep.add(line.gsub(/\n/, ''))
|
|
30
|
-
# end
|
|
31
|
-
# end
|
|
32
|
-
# return branches_to_keep
|
|
33
|
-
# end
|
|
34
|
-
|
|
35
|
-
# def clean_branches()
|
|
36
|
-
# branches_to_keep = Set.new ["master"]
|
|
37
|
-
# branches = `git branch`.split("\n")
|
|
38
|
-
# for branch in branches do
|
|
39
|
-
# branch = branch.gsub(/^\s+/, '')
|
|
40
|
-
# if branch.start_with?('*') || branches_to_keep.include?(branch)
|
|
41
|
-
# puts "Skipping branch " + branch.gsub(/^\*?\s*/, '')
|
|
42
|
-
# else
|
|
43
|
-
# system("git branch -d " + branch)
|
|
44
|
-
# end
|
|
45
|
-
# end
|
|
46
|
-
# end
|
|
47
|
-
#
|
|
48
|
-
# clean_branches()
|
metadata
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: branch_cleaner
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matt Flickner
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2020-03-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
|
-
description:
|
|
13
|
+
description: Are you tired of cleaning your git repository's branches manually? This
|
|
14
|
+
simple gem will delete all fully merged branches that are not the active branch
|
|
15
|
+
or the master branch.
|
|
14
16
|
email: mwflickner@gmail.com
|
|
15
17
|
executables:
|
|
16
18
|
- cleanbranches
|
|
@@ -43,5 +45,5 @@ rubyforge_project:
|
|
|
43
45
|
rubygems_version: 2.5.1
|
|
44
46
|
signing_key:
|
|
45
47
|
specification_version: 4
|
|
46
|
-
summary:
|
|
48
|
+
summary: A simple gem that will delete all fully merged branches
|
|
47
49
|
test_files: []
|