gitdummy 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
+ *.swp
3
+ .bundle
4
+ Gemfile.lock
5
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in gitdummy.gemspec
4
+ gemspec
5
+
@@ -0,0 +1,3 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.join(File.dirname(File.realpath(__FILE__)), '../lib/gitdummy')
4
+
5
+ Gitdummy::Cli.start
6
+
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "gitdummy/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "gitdummy"
7
+ s.version = Gitdummy::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = %w(aekym)
10
+ s.email = %w(me@aekym.com)
11
+ s.homepage = "http://aekym.com"
12
+ s.summary = %q{Small helper for a better start with git}
13
+ s.description = %q{'gitdummy' should help a fresh git user to make sure the config is correct and the current branch cares about public conventions.}
14
+
15
+ s.rubyforge_project = "gitdummy"
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
+ s.add_dependency('grit', '>= 2.4.1')
23
+ s.add_dependency('thor', '>= 0.14.6')
24
+ end
25
+
@@ -0,0 +1,38 @@
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ require 'grit'
4
+ require 'minitest/unit'
5
+ require 'thor'
6
+ require 'yaml'
7
+
8
+
9
+ module Gitdummy
10
+ class Cli < Thor
11
+ default_task :check
12
+
13
+ CONFIG_FILE = '.gitdummyrc'
14
+
15
+ def initialize(*args)
16
+ super
17
+
18
+ $repo = Grit::Repo.new('.')
19
+ $config = YAML.load_file(CONFIG_FILE) if File.readable?(CONFIG_FILE)
20
+ end
21
+
22
+ desc 'check', 'Check your current git repository and configuration'
23
+ method_options :'auto-fetch' => true
24
+ def check
25
+ system('git fetch') if options['auto-fetch']
26
+
27
+ test_dir = File.realpath('../lib/gitdummy/tests', File.dirname(__FILE__))
28
+
29
+ Dir["#{test_dir}/**/*_test.rb"].each do |file|
30
+ require file
31
+ end
32
+
33
+ MiniTest::Unit.new.run
34
+ end
35
+
36
+ end
37
+ end
38
+
@@ -0,0 +1,35 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ class ConfigTest < MiniTest::Unit::TestCase
4
+
5
+ def test_user_name
6
+ name = $repo.config['user.name'].force_encoding('utf-8')
7
+
8
+ # load configurable regexp to test the user's email
9
+ #
10
+ regexp = Regexp.new($config['tests']['config']['user']['name_regexp'].force_encoding('utf-8'))
11
+
12
+ assert_match regexp || /^\w+ \w+$/i, name,
13
+ "Please correct your user.name configuration with e.g. `git config user.name 'John Doe'`. `#{name}` not accepted"
14
+ end
15
+
16
+ def test_user_email
17
+ email = $repo.config['user.email'].force_encoding('utf-8')
18
+
19
+ # load configurable regexp to test the user's email
20
+ #
21
+ regexp = Regexp.new($config['tests']['config']['user']['email_regexp'].force_encoding('utf-8'))
22
+
23
+ assert_match regexp || /^[a-z]+\.[a-z]+@\w+\.\w+$/, email,
24
+ "Please correct your user.email configuration with e.g. `git config user.email 'john.doe@example.com'`. `#{email}` not accepted"
25
+ end
26
+
27
+ def test_default_tracking
28
+ push_default = $repo.config['push.default']
29
+
30
+ assert_equal 'tracking', push_default,
31
+ "Please correct you push.default configuration with `git config push.default tracking`. `#{push_default} no accepted."
32
+ end
33
+
34
+ end
35
+
@@ -0,0 +1,22 @@
1
+ class FeatureBranchTest < MiniTest::Unit::TestCase
2
+
3
+ def test_branch_of_origin_master
4
+ head = $repo.head.commit
5
+ origin_master_id = $repo.remotes.find{|r| r.name == 'origin/master'}.commit.id
6
+
7
+ current = head
8
+ found = false
9
+
10
+ while !found && current do
11
+ if current.id == origin_master_id
12
+ found = true
13
+ end
14
+
15
+ current = current.parents.first
16
+ end
17
+
18
+ assert found, "Your current branch is outdated and needs a rebase to the origin/master branch with `git rebase origin/master`."
19
+ end
20
+
21
+ end
22
+
@@ -0,0 +1,4 @@
1
+ module Gitdummy
2
+ VERSION = "0.0.1"
3
+ end
4
+
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gitdummy
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - aekym
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-03-06 00:00:00 +01:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: grit
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 2
30
+ - 4
31
+ - 1
32
+ version: 2.4.1
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: thor
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 0
45
+ - 14
46
+ - 6
47
+ version: 0.14.6
48
+ type: :runtime
49
+ version_requirements: *id002
50
+ description: "'gitdummy' should help a fresh git user to make sure the config is correct and the current branch cares about public conventions."
51
+ email:
52
+ - me@aekym.com
53
+ executables:
54
+ - gitdummy
55
+ extensions: []
56
+
57
+ extra_rdoc_files: []
58
+
59
+ files:
60
+ - .gitignore
61
+ - Gemfile
62
+ - Rakefile
63
+ - bin/gitdummy
64
+ - gitdummy.gemspec
65
+ - lib/gitdummy.rb
66
+ - lib/gitdummy/tests/config_test.rb
67
+ - lib/gitdummy/tests/feature_branch_test.rb
68
+ - lib/gitdummy/version.rb
69
+ has_rdoc: true
70
+ homepage: http://aekym.com
71
+ licenses: []
72
+
73
+ post_install_message:
74
+ rdoc_options: []
75
+
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ segments:
84
+ - 0
85
+ version: "0"
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ segments:
92
+ - 0
93
+ version: "0"
94
+ requirements: []
95
+
96
+ rubyforge_project: gitdummy
97
+ rubygems_version: 1.3.7
98
+ signing_key:
99
+ specification_version: 3
100
+ summary: Small helper for a better start with git
101
+ test_files: []
102
+