matthewtodd-doh 0.2.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.
data/CHANGELOG ADDED
@@ -0,0 +1,11 @@
1
+ == 0.2.2
2
+
3
+ * Documentation: Update for GitHub.
4
+
5
+ == 0.2.1
6
+
7
+ * Git: don't warn about modifications to tracked files when given "commit -a"
8
+
9
+ == 0.2.0
10
+
11
+ * Initial release
data/README ADDED
@@ -0,0 +1,35 @@
1
+ DDDDDDDDDDDDD hhhhhhh
2
+ D::::::::::::DDD h:::::h
3
+ D:::::::::::::::DD h:::::h
4
+ DDD:::::DDDDD:::::D h:::::h
5
+ D:::::D D:::::D ooooooooooo h::::h hhhhh
6
+ D:::::D D:::::D oo:::::::::::oo h::::hh:::::hhh
7
+ D:::::D D:::::Do:::::::::::::::o h::::::::::::::hh
8
+ D:::::D D:::::Do:::::ooooo:::::o h:::::::hhh::::::h
9
+ D:::::D D:::::Do::::o o::::o h::::::h h::::::h
10
+ D:::::D D:::::Do::::o o::::o h:::::h h:::::h
11
+ D:::::D D:::::Do::::o o::::o h:::::h h:::::h
12
+ D:::::D D:::::D o::::o o::::o h:::::h h:::::h
13
+ DDD:::::DDDDD:::::D o:::::ooooo:::::o h:::::h h:::::h
14
+ D:::::::::::::::DD o:::::::::::::::o h:::::h h:::::h ......
15
+ D::::::::::::DDD oo:::::::::::oo h:::::h h:::::h .::::.
16
+ DDDDDDDDDDDDD ooooooooooo hhhhhhh hhhhhhh ......
17
+
18
+ == INTRODUCTION
19
+
20
+ Doh stops your git or svn commit with a warning if you've forgotten to add some files.
21
+
22
+ == INSTALL
23
+
24
+ $ gem install matthewtodd-doh --source http://gems.github.com
25
+
26
+ == CONFIG
27
+
28
+ alias git='doh git'
29
+ alias svn='doh svn'
30
+
31
+ == SOURCE
32
+
33
+ git clone git://github.com/matthewtodd/doh.git
34
+
35
+ or {browse online}[http://github.com/matthewtodd/doh]
data/TODO ADDED
@@ -0,0 +1,2 @@
1
+ * TODO SVK support
2
+ * TODO Does this project become scm_hooks or something more general like that?
data/bin/doh ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+ require 'doh'
5
+
6
+ Doh::Cli.new(ARGV).run
data/lib/doh/cli.rb ADDED
@@ -0,0 +1,48 @@
1
+ class Doh::Cli
2
+ def initialize(args)
3
+ @args = args
4
+ @scm = Doh::Scm.const_get(@args.first.capitalize).new(@args)
5
+ rescue
6
+ $stderr.puts "Doh doesn't yet know how to support #{@args.first}. Perhaps you can help!"
7
+ exit 1
8
+ end
9
+
10
+ def run
11
+ exit_with_error if @scm.committing_with_unadded_files?
12
+ exec *@args
13
+ end
14
+
15
+
16
+ private
17
+
18
+ def exit_with_error
19
+ $stderr.puts red(DOH)
20
+ $stderr.puts @scm.unadded_files
21
+ exit 1
22
+ end
23
+
24
+ def red(string)
25
+ "\e[31m#{string}\e[0m"
26
+ end
27
+
28
+ # Ascii-art from http://www.schnoggo.com/figlet.html
29
+ # Selecting, appropriately, the font named "doh.flf"
30
+ DOH = <<-END.gsub(/^ /, '') #:nodoc:
31
+ DDDDDDDDDDDDD hhhhhhh
32
+ D::::::::::::DDD h:::::h
33
+ D:::::::::::::::DD h:::::h
34
+ DDD:::::DDDDD:::::D h:::::h
35
+ D:::::D D:::::D ooooooooooo h::::h hhhhh
36
+ D:::::D D:::::D oo:::::::::::oo h::::hh:::::hhh
37
+ D:::::D D:::::Do:::::::::::::::o h::::::::::::::hh
38
+ D:::::D D:::::Do:::::ooooo:::::o h:::::::hhh::::::h
39
+ D:::::D D:::::Do::::o o::::o h::::::h h::::::h
40
+ D:::::D D:::::Do::::o o::::o h:::::h h:::::h
41
+ D:::::D D:::::Do::::o o::::o h:::::h h:::::h
42
+ D:::::D D:::::D o::::o o::::o h:::::h h:::::h
43
+ DDD:::::DDDDD:::::D o:::::ooooo:::::o h:::::h h:::::h
44
+ D:::::::::::::::DD o:::::::::::::::o h:::::h h:::::h ......
45
+ D::::::::::::DDD oo:::::::::::oo h:::::h h:::::h .::::.
46
+ DDDDDDDDDDDDD ooooooooooo hhhhhhh hhhhhhh ......
47
+ END
48
+ end
@@ -0,0 +1,9 @@
1
+ class Doh::Scm::Base
2
+ def initialize(args)
3
+ @args = args
4
+ end
5
+
6
+ def committing_with_unadded_files?
7
+ committing? and unadded_files.any?
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ class Doh::Scm::Git < Doh::Scm::Base
2
+ def committing?
3
+ @args.include?('commit')
4
+ end
5
+
6
+ def unadded_files
7
+ pattern = if @args.include?('-a')
8
+ /(Untracked files:)/
9
+ else
10
+ /(Untracked files:)|(Changed but not updated:)/
11
+ end
12
+
13
+ warn = false
14
+ `git status`.grep(/^#/).select do |line|
15
+ warn = true if line =~ pattern
16
+ warn
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,9 @@
1
+ class Doh::Scm::Svn < Doh::Scm::Base
2
+ def committing?
3
+ @args.include?('ci') or @args.include?('commit')
4
+ end
5
+
6
+ def unadded_files
7
+ `svn st`.grep /^\?/
8
+ end
9
+ end
data/lib/doh/scm.rb ADDED
@@ -0,0 +1,6 @@
1
+ module Doh::Scm #:nodoc:
2
+ end
3
+
4
+ require 'doh/scm/base'
5
+ require 'doh/scm/git'
6
+ require 'doh/scm/svn'
data/lib/doh.rb ADDED
@@ -0,0 +1,5 @@
1
+ module Doh #:nodoc:
2
+ end
3
+
4
+ require 'doh/cli'
5
+ require 'doh/scm'
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: matthewtodd-doh
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.3
5
+ platform: ruby
6
+ authors:
7
+ - Matthew Todd
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-10-10 00:00:00 -07:00
13
+ default_executable: doh
14
+ dependencies: []
15
+
16
+ description:
17
+ email: matthew.todd@gmail.com
18
+ executables:
19
+ - doh
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README
24
+ - CHANGELOG
25
+ - TODO
26
+ files:
27
+ - README
28
+ - CHANGELOG
29
+ - TODO
30
+ - bin/doh
31
+ - lib/doh/cli.rb
32
+ - lib/doh/scm/base.rb
33
+ - lib/doh/scm/git.rb
34
+ - lib/doh/scm/svn.rb
35
+ - lib/doh/scm.rb
36
+ - lib/doh.rb
37
+ has_rdoc: true
38
+ homepage:
39
+ post_install_message:
40
+ rdoc_options: []
41
+
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: "0"
49
+ version:
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: "0"
55
+ version:
56
+ requirements: []
57
+
58
+ rubyforge_project:
59
+ rubygems_version: 1.2.0
60
+ signing_key:
61
+ specification_version: 2
62
+ summary: Doh stops your git or svn commit with a warning if you've forgotten to add some files.
63
+ test_files: []
64
+