legit 0.0.1 → 0.0.2

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/bin/legit ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift(File.expand_path("../../lib", __FILE__))
4
+ require 'legit'
5
+
6
+ Legit.start
data/legit.gemspec CHANGED
@@ -3,7 +3,7 @@ require File.expand_path("../lib/legit/version", __FILE__)
3
3
  Gem::Specification.new do |gem|
4
4
  gem.authors = ["Dillon Kearns"]
5
5
  gem.email = ["dillon@dillonkearns.com"]
6
- gem.description = "A collection of scripts for common git tasks, to simplify and improve workflow."
6
+ gem.description = "A collection of scripts for common git tasks to simplify and improve workflow."
7
7
  gem.summary = gem.description
8
8
  gem.homepage = "https://github.com/dillonkearns/legit"
9
9
 
@@ -18,4 +18,5 @@ 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
22
  end
data/lib/legit/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Legit
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/legit.rb ADDED
@@ -0,0 +1,44 @@
1
+ require 'legit_helper'
2
+ require 'thor'
3
+
4
+ class Legit < Thor
5
+ desc "log", "print a graph-like log"
6
+ def log
7
+ system("git log --pretty=format:'%C(yellow)%h%Creset%C(bold cyan)%d%Creset %s %Cgreen(%cr)%Creset %C(bold magenta) <%an>%Creset' --graph --abbrev-commit --date=relative")
8
+ end
9
+
10
+ desc "catch-todos [TODO_FORMAT]", "Abort commit if any todos in TODO_FORMAT found"
11
+ method_options %w[warn -w] => :boolean, :desc => 'Warn and prompt the user to choose whether to abort the commit'
12
+ def catch_todos(todo_format = "TODO")
13
+ system("git diff --staged | grep '^+' | grep #{todo_format}")
14
+
15
+ if $?.success?
16
+ if options[:warn]
17
+ exit 1 unless positive_response?("[pre-commit hook] Found staged `#{todo_format}`s. Do you still want to continue?", :warning)
18
+ else
19
+ show("[pre-commit hook] Aborting commit... found staged `#{todo_format}`s.", :warning)
20
+ exit 1
21
+ end
22
+ else
23
+ show("Success: No #{todo_format}s staged.", :success)
24
+ end
25
+ end
26
+
27
+ desc "delete BRANCH", "Delete BRANCH both locally and remotely"
28
+ def delete(branch_name)
29
+ system("git branch -d #{branch_name}")
30
+
31
+ if $?.success?
32
+ delete_remote_branch(branch_name)
33
+ else
34
+ show("Force delete branch #{branch_name}? (y/n)", :warning)
35
+ if STDIN.gets.chomp =~ /^y/
36
+ system("git branch -D #{branch_name}")
37
+ delete_remote_branch(branch_name)
38
+ else
39
+ puts "Abort. #{branch_name} not deleted"
40
+ end
41
+ end
42
+ end
43
+
44
+ end
data/lib/legit_helper.rb CHANGED
@@ -15,6 +15,8 @@ def show(message, type = :success)
15
15
  :green
16
16
  when :warning
17
17
  :red
18
+ when :normal
19
+ :white
18
20
  else
19
21
  raise 'Unknown prompt type'
20
22
  end
@@ -22,3 +24,8 @@ def show(message, type = :success)
22
24
  puts message.send(color)
23
25
  end
24
26
 
27
+
28
+ def positive_response?(message, type = :normal)
29
+ show("#{message} (y/n)", type)
30
+ STDIN.gets.chomp =~ /y/
31
+ end
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: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dillon Kearns
@@ -50,13 +50,27 @@ dependencies:
50
50
  prerelease: false
51
51
  name: colorize
52
52
  type: :runtime
53
- description: A collection of scripts for common git tasks, to simplify and improve workflow.
53
+ - !ruby/object:Gem::Dependency
54
+ version_requirements: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ~>
58
+ - !ruby/object:Gem::Version
59
+ hash: 95
60
+ segments:
61
+ - 0
62
+ - 16
63
+ - 0
64
+ version: 0.16.0
65
+ requirement: *id003
66
+ prerelease: false
67
+ name: thor
68
+ type: :runtime
69
+ description: A collection of scripts for common git tasks to simplify and improve workflow.
54
70
  email:
55
71
  - dillon@dillonkearns.com
56
72
  executables:
57
- - git-catch-todos
58
- - git-delete
59
- - git-push-upstream
73
+ - legit
60
74
  extensions: []
61
75
 
62
76
  extra_rdoc_files: []
@@ -67,10 +81,9 @@ files:
67
81
  - LICENSE
68
82
  - README.md
69
83
  - Rakefile
70
- - bin/git-catch-todos
71
- - bin/git-delete
72
- - bin/git-push-upstream
84
+ - bin/legit
73
85
  - legit.gemspec
86
+ - lib/legit.rb
74
87
  - lib/legit/version.rb
75
88
  - lib/legit_helper.rb
76
89
  has_rdoc: true
@@ -108,6 +121,6 @@ rubyforge_project:
108
121
  rubygems_version: 1.5.3
109
122
  signing_key:
110
123
  specification_version: 3
111
- summary: A collection of scripts for common git tasks, to simplify and improve workflow.
124
+ summary: A collection of scripts for common git tasks to simplify and improve workflow.
112
125
  test_files: []
113
126
 
data/bin/git-catch-todos DELETED
@@ -1,14 +0,0 @@
1
- #! /usr/bin/ruby
2
-
3
- require 'lib/legit_helper'
4
-
5
- todo_string = ARGV[0] || 'TODO'
6
- system("git diff --staged | grep '^+' | grep #{todo_string}")
7
-
8
- if $?.success?
9
- show("[pre-commit hook] Aborting commit... found staged `#{todo_string}`s.", :warning)
10
- exit 1
11
- else
12
- show("Success: No `#{todo_string}`s staged.", :success)
13
- exit 0
14
- end
data/bin/git-delete DELETED
@@ -1,19 +0,0 @@
1
- #! /usr/bin/ruby
2
-
3
- require 'lib/legit_helper'
4
-
5
- branch_name = ARGV[0] or raise 'Must pass in branch name'
6
-
7
- system("git branch -d #{branch_name}")
8
-
9
- if $?.success?
10
- delete_remote_branch(branch_name)
11
- else
12
- show("Force delete branch #{branch_name}? (y/n)", :warning)
13
- if STDIN.gets.chomp =~ /^y/
14
- system("git branch -D #{branch_name}")
15
- delete_remote_branch(branch_name)
16
- else
17
- puts "Abort. #{branch_name} not deleted"
18
- end
19
- end
@@ -1,19 +0,0 @@
1
- #! /usr/bin/ruby
2
-
3
- require 'lib/legit_helper'
4
-
5
- branch_name = ARGV[0] or raise 'Must pass in branch name'
6
-
7
- system("git branch -d #{branch_name}")
8
-
9
- if $?.success?
10
- delete_remote_branch(branch_name)
11
- else
12
- show("Force delete branch #{branch_name}? (y/n)", :warning)
13
- if STDIN.gets.chomp =~ /^y/
14
- system("git branch -D #{branch_name}")
15
- delete_remote_branch(branch_name)
16
- else
17
- puts "Abort. #{branch_name} not deleted"
18
- end
19
- end