gsbb 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .idea
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use ruby-1.9.3-rc1@gsbb --create
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in gsbb.gemspec
4
+ gemspec
@@ -0,0 +1,15 @@
1
+ require 'bundler'
2
+ require 'rake/clean'
3
+ require 'rake/testtask'
4
+ require 'cucumber'
5
+ require 'cucumber/rake/task'
6
+ require 'rdoc/task'
7
+ require 'grit'
8
+
9
+
10
+ require "bundler/gem_tasks"
11
+
12
+ Cucumber::Rake::Task.new(:features) do |t|
13
+ t.cucumber_opts = "features --format progress -x"
14
+ t.fork = false
15
+ end
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ require "rubygems" # ruby1.9 doesn't "require" it though
3
+ require "thor"
4
+ require "grit"
5
+ require 'date'
6
+ require File.expand_path(File.join(__FILE__, '..', '..', 'lib', 'gsbb'))
7
+
8
+ Gsbb.start
@@ -0,0 +1,9 @@
1
+ Feature: I can run my executable directly
2
+
3
+ Scenario: Executable works
4
+ When I run the app without parameters
5
+ Then the exit status should be 0
6
+
7
+ Scenario: Executable displays available commands
8
+ When I run the app without parameters
9
+ Then the output shows available commands
@@ -0,0 +1,9 @@
1
+ When /^I run the app without parameters$/ do
2
+ When %(I run `gsbb`)
3
+ end
4
+
5
+ Then /^the output shows available commands$/ do
6
+ Then %(the output should contain "show")
7
+ Then %(the output should contain "prune")
8
+ Then %(the output should contain "email")
9
+ end
@@ -0,0 +1,3 @@
1
+ require 'aruba/cucumber'
2
+
3
+ ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require 'thor'
4
+ require "gsbb/version"
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "gsbb"
8
+ s.version = Gsbb::VERSION
9
+ s.authors = ["Chris Apolzon"]
10
+ s.email = ["apolzon@gmail.com"]
11
+ s.homepage = "http://github.com/apolzon/gsbb"
12
+ s.summary = %q{Find and kill and blame those worthless stale branches}
13
+ s.description = %q{See summary}
14
+
15
+ s.rubyforge_project = "gsbb"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ # specify any dependencies here; for example:
23
+ # s.add_development_dependency "rspec"
24
+ # s.add_runtime_dependency "rest-client"
25
+ s.add_development_dependency "aruba"
26
+ s.add_dependency "thor"
27
+ s.add_dependency "grit"
28
+ end
@@ -0,0 +1,51 @@
1
+ class Gsbb < Thor
2
+ no_tasks do
3
+ def stale_branches
4
+ @stale_branches ||= branches.select do |branch|
5
+ commit = branch.commit
6
+ commit.authored_date.to_date < (Date.today - 21)
7
+ end
8
+ end
9
+
10
+ def branches
11
+ @branches ||= repo.remotes.reject { |r| r.name =~ /hackfest|HEAD|master|production|staging|performance/ }
12
+ @branches
13
+ end
14
+
15
+ def repo
16
+ @repo ||= ::Grit::Repo.new('./')
17
+ end
18
+ end
19
+
20
+ desc "show", "List stale branches"
21
+ def show
22
+ puts "Stale Branches:"
23
+ stale_branches.each do |branch|
24
+ puts "#{branch.name} - #{branch.commit.author}, #{(Date.today - branch.commit.authored_date.to_date).to_i} days old - #{branch.commit.authored_date.to_date}"
25
+ end
26
+ end
27
+
28
+ desc "prune", "Remove all stale branches from remote"
29
+ def prune
30
+ puts "Pruning:"
31
+ stale_branches.each do |branch|
32
+ name = branch.name.split("/").last
33
+
34
+ # Grit breaks here:
35
+ # puts repo.git.native(:push, {:raise => true}, "origin :#{name}")
36
+
37
+ puts `git push origin :#{name}`
38
+
39
+ if repo.heads.map(&:name).include?(name)
40
+ puts `git branch -D #{name}`
41
+ end
42
+ end
43
+ end
44
+
45
+ desc "email", "Email each stale branch author requesting branch removal"
46
+ def email
47
+ stale_branches.each do |branch|
48
+ puts branch.commit.to_hash['committer']['email'] # win!
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,3 @@
1
+ class Gsbb < Thor
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gsbb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Chris Apolzon
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-10-01 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: aruba
16
+ requirement: &70188188360940 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70188188360940
25
+ - !ruby/object:Gem::Dependency
26
+ name: thor
27
+ requirement: &70188188376180 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70188188376180
36
+ - !ruby/object:Gem::Dependency
37
+ name: grit
38
+ requirement: &70188188375620 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70188188375620
47
+ description: See summary
48
+ email:
49
+ - apolzon@gmail.com
50
+ executables:
51
+ - gsbb
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - .gitignore
56
+ - .rvmrc
57
+ - Gemfile
58
+ - Rakefile
59
+ - bin/gsbb
60
+ - features/gsbb.feature
61
+ - features/step_definitions/gsbb_steps.rb
62
+ - features/support/env.rb
63
+ - gsbb.gemspec
64
+ - lib/gsbb.rb
65
+ - lib/gsbb/version.rb
66
+ homepage: http://github.com/apolzon/gsbb
67
+ licenses: []
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ! '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubyforge_project: gsbb
86
+ rubygems_version: 1.8.10
87
+ signing_key:
88
+ specification_version: 3
89
+ summary: Find and kill and blame those worthless stale branches
90
+ test_files:
91
+ - features/gsbb.feature
92
+ - features/step_definitions/gsbb_steps.rb
93
+ - features/support/env.rb