git_snip 0.0.2 → 0.0.3
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/.travis.yml +1 -1
 - data/CHANGELOG.md +5 -0
 - data/Gemfile +4 -0
 - data/README.md +3 -1
 - data/git_snip.gemspec +3 -1
 - data/lib/git_snip/branch.rb +26 -0
 - data/lib/git_snip/cli.rb +12 -15
 - data/lib/git_snip/version.rb +1 -1
 - data/spec/lib/git_snip/branch_spec.rb +43 -0
 - data/spec/lib/git_snip/cli_spec.rb +10 -0
 - data/spec/spec_helper.rb +3 -0
 - data/spec/support/cli_helper.rb +23 -4
 - data/spec/support/cli_runner.rb +54 -0
 - metadata +9 -4
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 971bfdab966edf6e8d0f147bd19f85eb0f72c8ac
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: c8c3db3af432f657a11ff0e4bde9d292b26a10b3
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: b5d5cff6b4b5e2ba9b495925283b30d16e042a8c7b81e94ccc0f81b96acb71035fdf030927871593d69744ca2f2719c5edc08c569e0f454d72bdd57e0da511a0
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: c55e1e8fbe97572c4b8b858c65f4509170d87ac4d5f6e59c6c8899756cbca9650d05fc1679d900e5a9c9d349359c8ed152e99ea1e515398ee52c90dae6a3dfff
         
     | 
    
        data/.travis.yml
    CHANGED
    
    | 
         @@ -2,7 +2,7 @@ before_script: 
     | 
|
| 
       2 
2 
     | 
    
         
             
              - git config --global user.email "you@example.com"
         
     | 
| 
       3 
3 
     | 
    
         
             
              - git config --global user.name "Your Name"
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
            script: bundle exec rspec
         
     | 
| 
      
 5 
     | 
    
         
            +
            script: CODECLIMATE_REPO_TOKEN=ea0ada8842b47f59715526e88df53a81afff061152ce67bb73a8baa75443ea43 bundle exec rspec
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
            rvm:
         
     | 
| 
       8 
8 
     | 
    
         
             
              - 2.0.0
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        data/Gemfile
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | 
         @@ -1,6 +1,8 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # git-snip
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            [](https://travis-ci.org/htanata/git_snip)
         
     | 
| 
      
 4 
     | 
    
         
            +
            [](https://codeclimate.com/github/htanata/git_snip)
         
     | 
| 
      
 5 
     | 
    
         
            +
            [](https://codeclimate.com/github/htanata/git_snip)
         
     | 
| 
       4 
6 
     | 
    
         | 
| 
       5 
7 
     | 
    
         
             
            Clean obsolete branches on your git repository safely.
         
     | 
| 
       6 
8 
     | 
    
         | 
| 
         @@ -28,7 +30,7 @@ And then execute: 
     | 
|
| 
       28 
30 
     | 
    
         | 
| 
       29 
31 
     | 
    
         
             
            ## Usage
         
     | 
| 
       30 
32 
     | 
    
         | 
| 
       31 
     | 
    
         
            -
            Show branches which would be deleted:
         
     | 
| 
      
 33 
     | 
    
         
            +
            Show branches which would be deleted (accepts the same arguments as `-f`):
         
     | 
| 
       32 
34 
     | 
    
         | 
| 
       33 
35 
     | 
    
         
             
                $ git snip -n
         
     | 
| 
       34 
36 
     | 
    
         | 
    
        data/git_snip.gemspec
    CHANGED
    
    | 
         @@ -9,7 +9,7 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       9 
9 
     | 
    
         
             
              spec.authors       = ["Hendy Tanata"]
         
     | 
| 
       10 
10 
     | 
    
         
             
              spec.email         = ["htanata@gmail.com"]
         
     | 
| 
       11 
11 
     | 
    
         
             
              spec.summary       = %q{Clean obsolete branches on your local git repository safely}
         
     | 
| 
       12 
     | 
    
         
            -
              spec.homepage      = ""
         
     | 
| 
      
 12 
     | 
    
         
            +
              spec.homepage      = "https://github.com/htanata/git_snip"
         
     | 
| 
       13 
13 
     | 
    
         
             
              spec.license       = "MIT"
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
              spec.files         = `git ls-files -z`.split("\x0") - %w(Guardfile)
         
     | 
| 
         @@ -17,6 +17,8 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       17 
17 
     | 
    
         
             
              spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
         
     | 
| 
       18 
18 
     | 
    
         
             
              spec.require_paths = ["lib"]
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
      
 20 
     | 
    
         
            +
              spec.required_ruby_version = '>= 2.0'
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
       20 
22 
     | 
    
         
             
              spec.add_runtime_dependency "git"
         
     | 
| 
       21 
23 
     | 
    
         
             
              spec.add_runtime_dependency "thor"
         
     | 
| 
       22 
24 
     | 
    
         | 
| 
         @@ -0,0 +1,26 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module GitSnip
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Branch
         
     | 
| 
      
 3 
     | 
    
         
            +
                class Column < Struct.new(:sha, :name, :date, :author, :message)
         
     | 
| 
      
 4 
     | 
    
         
            +
                end
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                def self.columnize(branch)
         
     | 
| 
      
 7 
     | 
    
         
            +
                  Column.new.tap do |column|
         
     | 
| 
      
 8 
     | 
    
         
            +
                    column.sha = column(branch.gcommit.sha, 7)
         
     | 
| 
      
 9 
     | 
    
         
            +
                    column.name = column(branch.name, 12)
         
     | 
| 
      
 10 
     | 
    
         
            +
                    column.date = column(branch.gcommit.date.strftime('%F'), 10)
         
     | 
| 
      
 11 
     | 
    
         
            +
                    column.author = column(branch.gcommit.author.email.sub(/@.*/, ''), 8)
         
     | 
| 
      
 12 
     | 
    
         
            +
                    column.message = column(first_line(branch.gcommit.message), 39)
         
     | 
| 
      
 13 
     | 
    
         
            +
                  end
         
     | 
| 
      
 14 
     | 
    
         
            +
                end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                private
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                def self.column(string, width)
         
     | 
| 
      
 19 
     | 
    
         
            +
                  string[0, width].ljust(width)
         
     | 
| 
      
 20 
     | 
    
         
            +
                end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                def self.first_line(string)
         
     | 
| 
      
 23 
     | 
    
         
            +
                  string.gsub(/[\r\n].*/, '')
         
     | 
| 
      
 24 
     | 
    
         
            +
                end
         
     | 
| 
      
 25 
     | 
    
         
            +
              end
         
     | 
| 
      
 26 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/git_snip/cli.rb
    CHANGED
    
    | 
         @@ -1,5 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'thor'
         
     | 
| 
       2 
2 
     | 
    
         
             
            require 'git_snip/cleaner'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'git_snip/branch'
         
     | 
| 
       3 
4 
     | 
    
         | 
| 
       4 
5 
     | 
    
         
             
            module GitSnip
         
     | 
| 
       5 
6 
     | 
    
         
             
              class CLI < Thor
         
     | 
| 
         @@ -33,8 +34,7 @@ module GitSnip 
     | 
|
| 
       33 
34 
     | 
    
         | 
| 
       34 
35 
     | 
    
         
             
                  cleaner = GitSnip::Cleaner.new(*cleaner_args)
         
     | 
| 
       35 
36 
     | 
    
         | 
| 
       36 
     | 
    
         
            -
                  say  
     | 
| 
       37 
     | 
    
         
            -
                  say
         
     | 
| 
      
 37 
     | 
    
         
            +
                  say "Deleting the following branches...\n\n", :green
         
     | 
| 
       38 
38 
     | 
    
         | 
| 
       39 
39 
     | 
    
         
             
                  deleted_branches = cleaner.delete_merged_branches do |branch|
         
     | 
| 
       40 
40 
     | 
    
         
             
                    say_branch_info(branch)
         
     | 
| 
         @@ -44,7 +44,7 @@ module GitSnip 
     | 
|
| 
       44 
44 
     | 
    
         
             
                  if deleted_branches.empty?
         
     | 
| 
       45 
45 
     | 
    
         
             
                    say 'No branches were deleted.', :green
         
     | 
| 
       46 
46 
     | 
    
         
             
                  else
         
     | 
| 
       47 
     | 
    
         
            -
                    say "\ 
     | 
| 
      
 47 
     | 
    
         
            +
                    say "\nDone.", :green
         
     | 
| 
       48 
48 
     | 
    
         
             
                  end
         
     | 
| 
       49 
49 
     | 
    
         
             
                end
         
     | 
| 
       50 
50 
     | 
    
         
             
                default_task :snip
         
     | 
| 
         @@ -54,8 +54,7 @@ module GitSnip 
     | 
|
| 
       54 
54 
     | 
    
         
             
                def dry_run
         
     | 
| 
       55 
55 
     | 
    
         
             
                  cleaner = GitSnip::Cleaner.new(*cleaner_args)
         
     | 
| 
       56 
56 
     | 
    
         | 
| 
       57 
     | 
    
         
            -
                  say  
     | 
| 
       58 
     | 
    
         
            -
                  say
         
     | 
| 
      
 57 
     | 
    
         
            +
                  say "Would delete the following branches...\n\n", :green
         
     | 
| 
       59 
58 
     | 
    
         | 
| 
       60 
59 
     | 
    
         
             
                  merged_branches = cleaner.merged_branches
         
     | 
| 
       61 
60 
     | 
    
         | 
| 
         @@ -64,22 +63,20 @@ module GitSnip 
     | 
|
| 
       64 
63 
     | 
    
         
             
                  end
         
     | 
| 
       65 
64 
     | 
    
         | 
| 
       66 
65 
     | 
    
         
             
                  if merged_branches.any?
         
     | 
| 
       67 
     | 
    
         
            -
                    say "\ 
     | 
| 
      
 66 
     | 
    
         
            +
                    say "\nDone.", :green
         
     | 
| 
       68 
67 
     | 
    
         
             
                  else
         
     | 
| 
       69 
68 
     | 
    
         
             
                    say 'No branches would be deleted.', :green
         
     | 
| 
       70 
69 
     | 
    
         
             
                  end
         
     | 
| 
       71 
70 
     | 
    
         
             
                end
         
     | 
| 
       72 
71 
     | 
    
         | 
| 
       73 
72 
     | 
    
         
             
                def say_branch_info(branch)
         
     | 
| 
       74 
     | 
    
         
            -
                   
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
             
     | 
| 
       80 
     | 
    
         
            -
             
     | 
| 
       81 
     | 
    
         
            -
                def column(string, width, last: false)
         
     | 
| 
       82 
     | 
    
         
            -
                  string[0, width].ljust(last ? width : width + 1)
         
     | 
| 
      
 73 
     | 
    
         
            +
                  Branch.columnize(branch).tap do |column|
         
     | 
| 
      
 74 
     | 
    
         
            +
                    say column.sha + ' ', :yellow
         
     | 
| 
      
 75 
     | 
    
         
            +
                    say column.name + ' ', :magenta
         
     | 
| 
      
 76 
     | 
    
         
            +
                    say column.date + ' ', :green
         
     | 
| 
      
 77 
     | 
    
         
            +
                    say column.author + ' ', [:blue, :bold]
         
     | 
| 
      
 78 
     | 
    
         
            +
                    say column.message.strip + "\n"
         
     | 
| 
      
 79 
     | 
    
         
            +
                  end
         
     | 
| 
       83 
80 
     | 
    
         
             
                end
         
     | 
| 
       84 
81 
     | 
    
         | 
| 
       85 
82 
     | 
    
         
             
                def cleaner_args
         
     | 
    
        data/lib/git_snip/version.rb
    CHANGED
    
    
| 
         @@ -0,0 +1,43 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'git_snip/branch'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            RSpec.describe GitSnip::Branch do
         
     | 
| 
      
 4 
     | 
    
         
            +
              it 'should return values with number of characters within 80' do
         
     | 
| 
      
 5 
     | 
    
         
            +
                result = described_class.columnize(build_branch(build_column))
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                expect([
         
     | 
| 
      
 8 
     | 
    
         
            +
                  result.sha, result.name, result.author, result.date, result.message
         
     | 
| 
      
 9 
     | 
    
         
            +
                ].join(' ').size).to eq(80)
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              it 'should remove message starting from the first new line' do
         
     | 
| 
      
 13 
     | 
    
         
            +
                column = build_column(message: "First line\n\nThird line")
         
     | 
| 
      
 14 
     | 
    
         
            +
                result = described_class.columnize(build_branch(column))
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                expect(result.message).to eq('First line' + (' ' * 29))
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
              def build_branch(column)
         
     | 
| 
      
 20 
     | 
    
         
            +
                author = instance_double('Git::Author', email: column.author)
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                gcommit = instance_double(
         
     | 
| 
      
 23 
     | 
    
         
            +
                  'Git::Gcommit',
         
     | 
| 
      
 24 
     | 
    
         
            +
                  sha: column.sha,
         
     | 
| 
      
 25 
     | 
    
         
            +
                  date: column.date,
         
     | 
| 
      
 26 
     | 
    
         
            +
                  message: column.message,
         
     | 
| 
      
 27 
     | 
    
         
            +
                  author: author
         
     | 
| 
      
 28 
     | 
    
         
            +
                )
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                instance_double('Git::Branch', name: column.name, gcommit: gcommit)
         
     | 
| 
      
 31 
     | 
    
         
            +
              end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
              def build_column(attrs = {})
         
     | 
| 
      
 34 
     | 
    
         
            +
                described_class::Column.new.tap do |column|
         
     | 
| 
      
 35 
     | 
    
         
            +
                  column.sha = attrs[:sha] || '28720606978a7257f735ce67df50bc55ccf1c138'
         
     | 
| 
      
 36 
     | 
    
         
            +
                  column.name = attrs[:name] || 'a_pretty_long_branch_name'
         
     | 
| 
      
 37 
     | 
    
         
            +
                  column.author = attrs[:author] || 'inigo_montoya@example.com'
         
     | 
| 
      
 38 
     | 
    
         
            +
                  column.date = attrs[:date] || Time.now
         
     | 
| 
      
 39 
     | 
    
         
            +
                  column.message = attrs[:message] || 'Hello, my name is Inigo Montoya.'
         
     | 
| 
      
 40 
     | 
    
         
            +
                end
         
     | 
| 
      
 41 
     | 
    
         
            +
              end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -129,4 +129,14 @@ RSpec.describe GitSnip::CLI do 
     | 
|
| 
       129 
129 
     | 
    
         
             
                  expect(exitstatus).to eq(0)
         
     | 
| 
       130 
130 
     | 
    
         
             
                end
         
     | 
| 
       131 
131 
     | 
    
         
             
              end
         
     | 
| 
      
 132 
     | 
    
         
            +
             
     | 
| 
      
 133 
     | 
    
         
            +
              describe 'branch formatting' do
         
     | 
| 
      
 134 
     | 
    
         
            +
                it 'should add new line after each branch line' do
         
     | 
| 
      
 135 
     | 
    
         
            +
                  setup_basic_repo
         
     | 
| 
      
 136 
     | 
    
         
            +
             
     | 
| 
      
 137 
     | 
    
         
            +
                  stdout, _, _ = git_snip('--dry-run')
         
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
                  expect(stdout).to match(/merged.+Version 2\n/)
         
     | 
| 
      
 140 
     | 
    
         
            +
                end
         
     | 
| 
      
 141 
     | 
    
         
            +
              end
         
     | 
| 
       132 
142 
     | 
    
         
             
            end
         
     | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    
    
        data/spec/support/cli_helper.rb
    CHANGED
    
    | 
         @@ -1,12 +1,31 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require ' 
     | 
| 
      
 1 
     | 
    
         
            +
            require 'git_snip/cli'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require_relative 'cli_runner'
         
     | 
| 
       2 
3 
     | 
    
         | 
| 
       3 
4 
     | 
    
         
             
            module CliHelper
         
     | 
| 
      
 5 
     | 
    
         
            +
              class FakeKernel
         
     | 
| 
      
 6 
     | 
    
         
            +
                attr_reader :exitstatus
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                def initialize
         
     | 
| 
      
 9 
     | 
    
         
            +
                  @exitstatus = 0
         
     | 
| 
      
 10 
     | 
    
         
            +
                end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                def exit(exitstatus)
         
     | 
| 
      
 13 
     | 
    
         
            +
                  @exitstatus = exitstatus
         
     | 
| 
      
 14 
     | 
    
         
            +
                end
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
       4 
17 
     | 
    
         
             
              def git_snip(args = '')
         
     | 
| 
       5 
     | 
    
         
            -
                 
     | 
| 
      
 18 
     | 
    
         
            +
                stdin, stdout, stderr = Array.new(3) { StringIO.new }
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                runner =
         
     | 
| 
      
 21 
     | 
    
         
            +
                  GitSnip::CLIRunner.new("#{args} --repo=#{repo.path}".split(' '),
         
     | 
| 
      
 22 
     | 
    
         
            +
                    stdin, stdout, stderr, FakeKernel.new)
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                exitstatus = runner.execute!
         
     | 
| 
       6 
25 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
                stdout, stderr 
     | 
| 
      
 26 
     | 
    
         
            +
                [stdin, stdout, stderr].each(&:rewind)
         
     | 
| 
       8 
27 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
                [stdout, stderr,  
     | 
| 
      
 28 
     | 
    
         
            +
                [stdout.read, stderr.read, exitstatus]
         
     | 
| 
       10 
29 
     | 
    
         
             
              end
         
     | 
| 
       11 
30 
     | 
    
         | 
| 
       12 
31 
     | 
    
         
             
              def setup_basic_repo
         
     | 
| 
         @@ -0,0 +1,54 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'git_snip/cli'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # https://github.com/erikhuda/thor/wiki/Integrating-with-Aruba-In-Process-Runs
         
     | 
| 
      
 4 
     | 
    
         
            +
            module GitSnip
         
     | 
| 
      
 5 
     | 
    
         
            +
              class CLIRunner
         
     | 
| 
      
 6 
     | 
    
         
            +
                # Allow everything fun to be injected from the outside while defaulting to
         
     | 
| 
      
 7 
     | 
    
         
            +
                # normal implementations.
         
     | 
| 
      
 8 
     | 
    
         
            +
                def initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel)
         
     | 
| 
      
 9 
     | 
    
         
            +
                  @argv, @stdin, @stdout, @stderr, @kernel = argv, stdin, stdout, stderr, kernel
         
     | 
| 
      
 10 
     | 
    
         
            +
                end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                def execute!
         
     | 
| 
      
 13 
     | 
    
         
            +
                  exit_code = begin
         
     | 
| 
      
 14 
     | 
    
         
            +
                    # Thor accesses these streams directly rather than letting them be
         
     | 
| 
      
 15 
     | 
    
         
            +
                    # injected, so replace them.
         
     | 
| 
      
 16 
     | 
    
         
            +
                    $stderr = @stderr
         
     | 
| 
      
 17 
     | 
    
         
            +
                    $stderr = @stderr
         
     | 
| 
      
 18 
     | 
    
         
            +
                    $stdin = @stdin
         
     | 
| 
      
 19 
     | 
    
         
            +
                    $stdout = @stdout
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                    GitSnip::CLI.start(@argv)
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                    # Thor::Base#start does not have a return value, assume success if no
         
     | 
| 
      
 24 
     | 
    
         
            +
                    # exception is raised.
         
     | 
| 
      
 25 
     | 
    
         
            +
                    0
         
     | 
| 
      
 26 
     | 
    
         
            +
                  rescue StandardError => e
         
     | 
| 
      
 27 
     | 
    
         
            +
                    # The ruby interpreter would pipe this to STDERR and exit 1 in the case
         
     | 
| 
      
 28 
     | 
    
         
            +
                    # of an unhandled exception.
         
     | 
| 
      
 29 
     | 
    
         
            +
                    b = e.backtrace
         
     | 
| 
      
 30 
     | 
    
         
            +
                    @stderr.puts("#{b.shift}: #{e.message} (#{e.class})")
         
     | 
| 
      
 31 
     | 
    
         
            +
                    @stderr.puts(b.map{|s| "\tfrom #{s}"}.join("\n"))
         
     | 
| 
      
 32 
     | 
    
         
            +
                    1
         
     | 
| 
      
 33 
     | 
    
         
            +
                  rescue SystemExit => e
         
     | 
| 
      
 34 
     | 
    
         
            +
                    e.status
         
     | 
| 
      
 35 
     | 
    
         
            +
                  ensure
         
     | 
| 
      
 36 
     | 
    
         
            +
                    # Reset your app here, free up resources, etc.
         
     | 
| 
      
 37 
     | 
    
         
            +
                    # Examples:
         
     | 
| 
      
 38 
     | 
    
         
            +
                    # MyApp.logger.flush
         
     | 
| 
      
 39 
     | 
    
         
            +
                    # MyApp.logger.close
         
     | 
| 
      
 40 
     | 
    
         
            +
                    # MyApp.logger = nil
         
     | 
| 
      
 41 
     | 
    
         
            +
                    #
         
     | 
| 
      
 42 
     | 
    
         
            +
                    # MyApp.reset_singleton_instance_variables
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                    # Then we put the streams back.
         
     | 
| 
      
 45 
     | 
    
         
            +
                    $stderr = STDERR
         
     | 
| 
      
 46 
     | 
    
         
            +
                    $stdin = STDIN
         
     | 
| 
      
 47 
     | 
    
         
            +
                    $stdout = STDOUT
         
     | 
| 
      
 48 
     | 
    
         
            +
                  end
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                  # Proxy our exit code back to the injected kernel.
         
     | 
| 
      
 51 
     | 
    
         
            +
                  @kernel.exit(exit_code)
         
     | 
| 
      
 52 
     | 
    
         
            +
                end
         
     | 
| 
      
 53 
     | 
    
         
            +
              end
         
     | 
| 
      
 54 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: git_snip
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.3
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Hendy Tanata
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2015-02- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2015-02-12 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: git
         
     | 
| 
         @@ -99,15 +99,18 @@ files: 
     | 
|
| 
       99 
99 
     | 
    
         
             
            - bin/git-snip
         
     | 
| 
       100 
100 
     | 
    
         
             
            - git_snip.gemspec
         
     | 
| 
       101 
101 
     | 
    
         
             
            - lib/git_snip.rb
         
     | 
| 
      
 102 
     | 
    
         
            +
            - lib/git_snip/branch.rb
         
     | 
| 
       102 
103 
     | 
    
         
             
            - lib/git_snip/cleaner.rb
         
     | 
| 
       103 
104 
     | 
    
         
             
            - lib/git_snip/cli.rb
         
     | 
| 
       104 
105 
     | 
    
         
             
            - lib/git_snip/version.rb
         
     | 
| 
      
 106 
     | 
    
         
            +
            - spec/lib/git_snip/branch_spec.rb
         
     | 
| 
       105 
107 
     | 
    
         
             
            - spec/lib/git_snip/cleaner_spec.rb
         
     | 
| 
       106 
108 
     | 
    
         
             
            - spec/lib/git_snip/cli_spec.rb
         
     | 
| 
       107 
109 
     | 
    
         
             
            - spec/spec_helper.rb
         
     | 
| 
       108 
110 
     | 
    
         
             
            - spec/support/cli_helper.rb
         
     | 
| 
      
 111 
     | 
    
         
            +
            - spec/support/cli_runner.rb
         
     | 
| 
       109 
112 
     | 
    
         
             
            - spec/support/repo.rb
         
     | 
| 
       110 
     | 
    
         
            -
            homepage:  
     | 
| 
      
 113 
     | 
    
         
            +
            homepage: https://github.com/htanata/git_snip
         
     | 
| 
       111 
114 
     | 
    
         
             
            licenses:
         
     | 
| 
       112 
115 
     | 
    
         
             
            - MIT
         
     | 
| 
       113 
116 
     | 
    
         
             
            metadata: {}
         
     | 
| 
         @@ -119,7 +122,7 @@ required_ruby_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       119 
122 
     | 
    
         
             
              requirements:
         
     | 
| 
       120 
123 
     | 
    
         
             
              - - ">="
         
     | 
| 
       121 
124 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       122 
     | 
    
         
            -
                  version: '0'
         
     | 
| 
      
 125 
     | 
    
         
            +
                  version: '2.0'
         
     | 
| 
       123 
126 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       124 
127 
     | 
    
         
             
              requirements:
         
     | 
| 
       125 
128 
     | 
    
         
             
              - - ">="
         
     | 
| 
         @@ -132,8 +135,10 @@ signing_key: 
     | 
|
| 
       132 
135 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       133 
136 
     | 
    
         
             
            summary: Clean obsolete branches on your local git repository safely
         
     | 
| 
       134 
137 
     | 
    
         
             
            test_files:
         
     | 
| 
      
 138 
     | 
    
         
            +
            - spec/lib/git_snip/branch_spec.rb
         
     | 
| 
       135 
139 
     | 
    
         
             
            - spec/lib/git_snip/cleaner_spec.rb
         
     | 
| 
       136 
140 
     | 
    
         
             
            - spec/lib/git_snip/cli_spec.rb
         
     | 
| 
       137 
141 
     | 
    
         
             
            - spec/spec_helper.rb
         
     | 
| 
       138 
142 
     | 
    
         
             
            - spec/support/cli_helper.rb
         
     | 
| 
      
 143 
     | 
    
         
            +
            - spec/support/cli_runner.rb
         
     | 
| 
       139 
144 
     | 
    
         
             
            - spec/support/repo.rb
         
     |