git-cleanup 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +38 -0
- data/bin/git-cleanup +4 -1
- data/git-cleanup.gemspec +3 -3
- data/lib/git-cleanup.rb +6 -5
- data/lib/git-cleanup/version.rb +1 -1
- metadata +23 -16
- data/.document +0 -5
- data/README.rdoc +0 -17
- data/VERSION +0 -1
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# git-cleanup
|
2
|
+
|
3
|
+
A simple interactive command line tool to help you cleanup your git branch detritus.
|
4
|
+
|
5
|
+
This is what git-cleanup does:
|
6
|
+
|
7
|
+
1. Iterates over all remote branches (assumes origin), starting with the newest. For each branch:
|
8
|
+
2. If the branch has been merged into master it offers to delete it, first remotely then locally.
|
9
|
+
3. If the branch has not been merged it shows you all the un-merged commits, and offers to show you a diff (in your `GIT_EDITOR`). This makes it easy to determine whether the branch should be removed or not.
|
10
|
+
Once you have viewed the diff you will be asked whether you wish to delete the branch as before.
|
11
|
+
|
12
|
+
**Every destructive operation is interactive** - nothing unexpected will happen to your repo. It's perfectly fine to `Ctrl-C` at any time if you get bored of deleting branches and want to do some real work.
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
Install the gem
|
17
|
+
|
18
|
+
$ gem install git-cleanup
|
19
|
+
|
20
|
+
Inside a git repo, just run git-cleanup
|
21
|
+
|
22
|
+
$ git-cleanup
|
23
|
+
|
24
|
+
Use `--skip-unmerged` to ignore un-merged branches
|
25
|
+
|
26
|
+
$ git-cleanup --skip-unmerged
|
27
|
+
|
28
|
+
Use `--only` to only consider branch names that have this substring
|
29
|
+
|
30
|
+
$ git-cleanup --only myname
|
31
|
+
|
32
|
+
Be careful, if you delete a critical branch it's not my fault. Piping in `yes` is a bad idea.
|
33
|
+
|
34
|
+
## Hacking
|
35
|
+
|
36
|
+
There are no tests, this was a quick hack to get the job done.
|
37
|
+
|
38
|
+
Pragmatic patches welcome, please open an issue first to discuss.
|
data/bin/git-cleanup
CHANGED
@@ -12,9 +12,12 @@ conf = {
|
|
12
12
|
|
13
13
|
opts = OptionParser.new do |opts|
|
14
14
|
opts.banner = "Usage: git-cleanup [OPTIONS] -- ... commands"
|
15
|
-
opts.on("-s", "--skip-unmerged", "
|
15
|
+
opts.on("-s", "--skip-unmerged", "Unmerged branches will be skipped") do |u|
|
16
16
|
conf[:skip_unmerged] = true
|
17
17
|
end
|
18
|
+
opts.on("-o","--only FILTER", "Only branches that match FILTER will be included") do |only_filter|
|
19
|
+
conf[:only_filter] = only_filter
|
20
|
+
end
|
18
21
|
opts.on("-v", "--version", "Shows version") do
|
19
22
|
puts GitCleanup::VERSION
|
20
23
|
exit
|
data/git-cleanup.gemspec
CHANGED
@@ -8,9 +8,9 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
9
|
s.authors = ["Martyn Loughran"]
|
10
10
|
s.email = ["me@mloughran.com"]
|
11
|
-
s.homepage = "http://github.com/
|
12
|
-
s.summary = %q{
|
13
|
-
s.description = %q{
|
11
|
+
s.homepage = "http://mloughran.github.com/git-cleanup/"
|
12
|
+
s.summary = %q{A simple interactive command line tool to help you cleanup your git branch detritus}
|
13
|
+
s.description = %q{A simple interactive command line tool to help you cleanup your git branch detritus}
|
14
14
|
|
15
15
|
s.add_dependency 'grit', '~> 2.2.0'
|
16
16
|
s.add_dependency 'formatador', '~> 0.2.1'
|
data/lib/git-cleanup.rb
CHANGED
@@ -24,6 +24,7 @@ class GitCleanup
|
|
24
24
|
|
25
25
|
remote_branches.sort.reverse.each_with_index do |branch, index|
|
26
26
|
next if branch.name == 'master'
|
27
|
+
next if options[:only_filter] and !branch.name.match(options[:only_filter])
|
27
28
|
|
28
29
|
# Diff of commit in branch which is not in master
|
29
30
|
diff = branch.diff(master)
|
@@ -36,7 +37,7 @@ class GitCleanup
|
|
36
37
|
Formatador.display_line "[bold][green]" + '-' * msg.size + "[/]"
|
37
38
|
|
38
39
|
if diff.empty?
|
39
|
-
Formatador.display_line "Branch merged. Last commit on branch:"
|
40
|
+
Formatador.display_line "[bold]Branch merged.[/] Last commit on branch:"
|
40
41
|
last_commit = branch.commit
|
41
42
|
if last_commit
|
42
43
|
Formatador.indent {
|
@@ -47,22 +48,22 @@ class GitCleanup
|
|
47
48
|
}
|
48
49
|
end
|
49
50
|
|
50
|
-
Helper.boolean 'Do you want the branch deleted?' do
|
51
|
+
Helper.boolean '[bold]Branch merged.[/] Do you want the branch deleted?' do
|
51
52
|
branch.delete(local_branches)
|
52
53
|
end
|
53
54
|
else
|
54
55
|
if options[:skip_unmerged]
|
55
|
-
Helper.info "Branch not merged. Skipped"
|
56
|
+
Helper.info "[bold]Branch not merged.[/] Skipped"
|
56
57
|
next
|
57
58
|
end
|
58
59
|
|
59
|
-
Formatador.display_line "Branch not merged. Commits on branch:"
|
60
|
+
Formatador.display_line "[bold]Branch not merged.[/] Commits on branch:"
|
60
61
|
|
61
62
|
Formatador.indent {
|
62
63
|
Formatador.display_lines commits.split("\n")
|
63
64
|
}
|
64
65
|
|
65
|
-
Helper.boolean "Do you want to see a diff?" do
|
66
|
+
Helper.boolean "[bold]Branch not merged.[/] Do you want to see a diff?" do
|
66
67
|
Tempfile.open('diff') do |tempfile|
|
67
68
|
tempfile << diff
|
68
69
|
tempfile.flush
|
data/lib/git-cleanup/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-cleanup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: grit
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: 2.2.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.2.0
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: formatador
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ~>
|
@@ -32,9 +37,14 @@ dependencies:
|
|
32
37
|
version: 0.2.1
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
-
|
37
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.2.1
|
46
|
+
description: A simple interactive command line tool to help you cleanup your git branch
|
47
|
+
detritus
|
38
48
|
email:
|
39
49
|
- me@mloughran.com
|
40
50
|
executables:
|
@@ -42,20 +52,18 @@ executables:
|
|
42
52
|
extensions: []
|
43
53
|
extra_rdoc_files: []
|
44
54
|
files:
|
45
|
-
- .document
|
46
55
|
- .gitignore
|
47
56
|
- Gemfile
|
48
57
|
- LICENSE
|
49
|
-
- README.
|
58
|
+
- README.md
|
50
59
|
- Rakefile
|
51
|
-
- VERSION
|
52
60
|
- bin/git-cleanup
|
53
61
|
- git-cleanup.gemspec
|
54
62
|
- lib/git-cleanup.rb
|
55
63
|
- lib/git-cleanup/branch.rb
|
56
64
|
- lib/git-cleanup/helper.rb
|
57
65
|
- lib/git-cleanup/version.rb
|
58
|
-
homepage: http://github.com/
|
66
|
+
homepage: http://mloughran.github.com/git-cleanup/
|
59
67
|
licenses: []
|
60
68
|
post_install_message:
|
61
69
|
rdoc_options: []
|
@@ -75,10 +83,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
83
|
version: '0'
|
76
84
|
requirements: []
|
77
85
|
rubyforge_project:
|
78
|
-
rubygems_version: 1.8.
|
86
|
+
rubygems_version: 1.8.24
|
79
87
|
signing_key:
|
80
88
|
specification_version: 3
|
81
|
-
summary:
|
82
|
-
|
89
|
+
summary: A simple interactive command line tool to help you cleanup your git branch
|
90
|
+
detritus
|
83
91
|
test_files: []
|
84
|
-
has_rdoc:
|
data/.document
DELETED
data/README.rdoc
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
= git-cleanup
|
2
|
-
|
3
|
-
Description goes here.
|
4
|
-
|
5
|
-
== Note on Patches/Pull Requests
|
6
|
-
|
7
|
-
* Fork the project.
|
8
|
-
* Make your feature addition or bug fix.
|
9
|
-
* Add tests for it. This is important so I don't break it in a
|
10
|
-
future version unintentionally.
|
11
|
-
* Commit, do not mess with rakefile, version, or history.
|
12
|
-
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
13
|
-
* Send me a pull request. Bonus points for topic branches.
|
14
|
-
|
15
|
-
== Copyright
|
16
|
-
|
17
|
-
Copyright (c) 2010 Martyn Loughran. See LICENSE for details.
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.1.2
|