legit 0.0.5 → 0.0.6

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.
data/README.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # Legit [![Dependency Status](https://gemnasium.com/dillonkearns/legit.png)](https://gemnasium.com/dillonkearns/legit) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/dillonkearns/dotfile-linker)
2
2
 
3
+ ## Installation
4
+ ```bash
5
+ $ gem install legit
6
+ ```
7
+
8
+ ## Usage
9
+ Run `legit` with no options to see a list of commands and options.
10
+
11
+ ### Setting Up a `catch-todos` `pre-commit` Hook
12
+ ![$ git up](http://i.imgur.com/rv0AfQi.png)
13
+
14
+ 1. Add the following to `.git/hooks/pre-commit` in the desired repository:
15
+ ```bash
16
+ #! /bin/bash
17
+ legit catch-todos TODO
18
+ ```
19
+
20
+ 2. Make the hook executable (git will silently ignore your hook otherwise):
21
+ ```bash
22
+ chmod +x .git/hooks/pre-commit
23
+ ```
24
+
25
+ Note: if you use a graphical git tool (such as [SourceTree](http://http://www.sourcetreeapp.com/) for OS X), you may need read the following:
26
+
27
+ RVM and similar tools do store executables in custom locations instead of the standard locations for executables such as `/usr/bin`. Since your `.bash_profile` (or similar) might not be executed by your GUI tool, you may need to create a symlink to legit in a location that is in the tool's default path. `/usr/bin` is usually included, so this should do:
28
+ ```bash
29
+ sudo ln -s $(which legit) /usr/bin/legit # find where RVM is storing legit and add a symlink to it in /usr/bin
30
+ ```
31
+
3
32
  ## Contributing
4
33
 
5
34
  1. Fork it
@@ -18,5 +18,6 @@ Gem::Specification.new do |gem|
18
18
 
19
19
  gem.add_development_dependency "rake", "~> 10.0.3"
20
20
  gem.add_runtime_dependency "colorize", "~> 0.5.8"
21
- gem.add_runtime_dependency "thor", "~> 0.16.0"
21
+ gem.add_runtime_dependency "thor", "~> 0.17.0"
22
+ gem.add_runtime_dependency "rugged", "0.17.0.b7"
22
23
  end
@@ -17,18 +17,19 @@ class Legit < Thor
17
17
 
18
18
  desc "catch-todos [TODO_FORMAT]", "Abort commit if any todos in TODO_FORMAT found"
19
19
  method_option :warn, :type => :boolean, :aliases => "-w", :desc => 'Warn and prompt the user to choose whether to abort the commit'
20
+ method_option :enable, :type => :boolean, :desc => 'Enable todo checking'
21
+ method_option :disable, :type => :boolean, :desc => 'Disable todo checking'
20
22
  def catch_todos(todo_format = "TODO")
21
- system("git diff --staged | grep '^+' | grep #{todo_format}")
22
-
23
- if $?.success?
24
- if options[:warn]
25
- exit 1 unless positive_response?("[pre-commit hook] Found staged `#{todo_format}`s. Do you still want to continue?", :warning)
23
+ if options[:enable]
24
+ repo.config.delete('hooks.ignore-todos')
25
+ elsif options[:disable]
26
+ repo.config['hooks.ignore-todos'] = true
27
+ else
28
+ if repo.config['hooks.ignore-todos'] == 'true'
29
+ show("[pre-commit hook] ignoring todos. Re-enable with `legit catch-todos --enable`", :low_warning)
26
30
  else
27
- show("[pre-commit hook] Aborting commit... found staged `#{todo_format}`s.", :warning)
28
- exit 1
31
+ run_catch_todos(todo_format)
29
32
  end
30
- else
31
- show("Success: No #{todo_format}s staged.", :success)
32
33
  end
33
34
  end
34
35
 
@@ -49,4 +50,23 @@ class Legit < Thor
49
50
  end
50
51
  end
51
52
 
53
+ private
54
+ def repo
55
+ @repo ||= Rugged::Repository.new('.')
56
+ end
57
+
58
+ def run_catch_todos(todo_format)
59
+ system("git diff --staged | grep '^+' | grep #{todo_format}")
60
+
61
+ if $?.success?
62
+ if options[:warn]
63
+ exit 1 unless positive_response?("[pre-commit hook] Found staged `#{todo_format}`s. Do you still want to continue?", :warning)
64
+ else
65
+ show("[pre-commit hook] Aborting commit... found staged `#{todo_format}`s.", :warning)
66
+ exit 1
67
+ end
68
+ else
69
+ show("Success: No #{todo_format}s staged.", :success)
70
+ end
71
+ end
52
72
  end
@@ -1,3 +1,3 @@
1
1
  module Legit
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -1,4 +1,5 @@
1
1
  require 'colorize'
2
+ require 'rugged'
2
3
 
3
4
  def current_branch
4
5
  system "git rev-parse --abbrev-ref HEAD"
@@ -23,6 +24,8 @@ def show(message, type = :success)
23
24
  :green
24
25
  when :warning
25
26
  :red
27
+ when :low_warning
28
+ :yellow
26
29
  when :normal
27
30
  :white
28
31
  else
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: legit
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dillon Kearns
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-01-12 00:00:00 -08:00
18
+ date: 2013-02-04 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -56,16 +56,34 @@ dependencies:
56
56
  requirements:
57
57
  - - ~>
58
58
  - !ruby/object:Gem::Version
59
- hash: 95
59
+ hash: 91
60
60
  segments:
61
61
  - 0
62
- - 16
62
+ - 17
63
63
  - 0
64
- version: 0.16.0
64
+ version: 0.17.0
65
65
  requirement: *id003
66
66
  prerelease: false
67
67
  name: thor
68
68
  type: :runtime
69
+ - !ruby/object:Gem::Dependency
70
+ version_requirements: &id004 !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - "="
74
+ - !ruby/object:Gem::Version
75
+ hash: -2833707614
76
+ segments:
77
+ - 0
78
+ - 17
79
+ - 0
80
+ - b
81
+ - 7
82
+ version: 0.17.0.b7
83
+ requirement: *id004
84
+ prerelease: false
85
+ name: rugged
86
+ type: :runtime
69
87
  description: A collection of scripts for common git tasks to simplify and improve workflow.
70
88
  email:
71
89
  - dillon@dillonkearns.com