git-branch-delete-orphans 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +1 -0
- data/bin/git-branch-delete-orphans +39 -0
- data/git-branch-delete-orphans.gemspec +24 -0
- data/lib/git-branch-delete-orphans.rb +11 -0
- data/lib/git-branch-delete-orphans/version.rb +9 -0
- metadata +74 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,39 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
def remotes
|
4
|
+
puts "Listing remote branches..."
|
5
|
+
@remote ||= `git ls-remote | grep 'refs/heads'`.map { |l| l.gsub(/^.*refs\/heads\//, '').strip }
|
6
|
+
end
|
7
|
+
|
8
|
+
def locals
|
9
|
+
@local ||= `cat .git/config | grep "refs/heads/\\w"`.map { |l| l.gsub(/^.*refs\/heads\//, '').strip }
|
10
|
+
end
|
11
|
+
|
12
|
+
def cli(orphans)
|
13
|
+
puts ""
|
14
|
+
puts "The following branches track a remote branch which does not exist anymore:"
|
15
|
+
orphans.each { |b| puts " - #{b}" }
|
16
|
+
|
17
|
+
delete_all = false
|
18
|
+
keep_all = false
|
19
|
+
orphans.each do |b|
|
20
|
+
delete = false
|
21
|
+
keep = false
|
22
|
+
until delete || delete_all || keep || keep_all
|
23
|
+
puts ""
|
24
|
+
puts "#{b} tracks a remote branch which does not exist anymore. Do you want to [d]elete it, [D]elete all, [k]eep it or [K]eep all?"
|
25
|
+
case STDIN.gets.chomp
|
26
|
+
when 'd' then delete = true
|
27
|
+
when 'D' then delete_all = true
|
28
|
+
when 'k' then keep = true
|
29
|
+
when 'K' then keep_all = true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
if (delete_all || delete) && !(keep_all || keep)
|
33
|
+
system("git branch -D #{b}") # git outputs success / error messages
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
orphans = locals - remotes
|
39
|
+
cli(orphans)
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "git-branch-delete-orphans/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "git-branch-delete-orphans"
|
7
|
+
s.version = Git::Branch::Delete::Orphans::VERSION
|
8
|
+
s.authors = ["Philippe Creux"]
|
9
|
+
s.email = ["pcreux@gmail.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Delete tracking branches which remote branch does not exist anymore.}
|
12
|
+
s.description = %q{`git branch-delete-orphans` lists orphan tracking branches and prompts you to delete or keep them.}
|
13
|
+
|
14
|
+
s.default_executable = %q{git-branch-delete-orphans}
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
# s.add_development_dependency "rspec"
|
23
|
+
# s.add_runtime_dependency "rest-client"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: git-branch-delete-orphans
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Philippe Creux
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-10-17 00:00:00 +02:00
|
19
|
+
default_executable: git-branch-delete-orphans
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: `git branch-delete-orphans` lists orphan tracking branches and prompts you to delete or keep them.
|
23
|
+
email:
|
24
|
+
- pcreux@gmail.com
|
25
|
+
executables:
|
26
|
+
- git-branch-delete-orphans
|
27
|
+
extensions: []
|
28
|
+
|
29
|
+
extra_rdoc_files: []
|
30
|
+
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- Gemfile
|
34
|
+
- Rakefile
|
35
|
+
- bin/git-branch-delete-orphans
|
36
|
+
- git-branch-delete-orphans.gemspec
|
37
|
+
- lib/git-branch-delete-orphans.rb
|
38
|
+
- lib/git-branch-delete-orphans/version.rb
|
39
|
+
has_rdoc: true
|
40
|
+
homepage: ""
|
41
|
+
licenses: []
|
42
|
+
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options: []
|
45
|
+
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
hash: 3
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
version: "0"
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
hash: 3
|
63
|
+
segments:
|
64
|
+
- 0
|
65
|
+
version: "0"
|
66
|
+
requirements: []
|
67
|
+
|
68
|
+
rubyforge_project:
|
69
|
+
rubygems_version: 1.3.7
|
70
|
+
signing_key:
|
71
|
+
specification_version: 3
|
72
|
+
summary: Delete tracking branches which remote branch does not exist anymore.
|
73
|
+
test_files: []
|
74
|
+
|