mobi_check_in 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/bin/ci +6 -0
- data/bin/cic +4 -0
- data/bin/cii +5 -0
- data/lib/mobi_check_in/git.rb +19 -0
- data/lib/mobi_check_in/version.rb +3 -0
- data/lib/mobi_check_in.rb +90 -0
- data/mobi_check_in.gemspec +19 -0
- metadata +60 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 David Kormushoff
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# MobiCheckIn
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'mobi_check_in'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install mobi_check_in
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/ci
ADDED
data/bin/cic
ADDED
data/bin/cii
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module MobiCheckIn
|
2
|
+
module Git
|
3
|
+
def self.current_branch
|
4
|
+
`git branch --no-color 2> /dev/null`.split("\n")
|
5
|
+
.select{ |branch| branch.match(/\* /) }
|
6
|
+
.first
|
7
|
+
.split("* ")
|
8
|
+
.last
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.local_commits
|
12
|
+
`git log origin/#{current_branch}..HEAD`
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.has_local_changes?
|
16
|
+
!`git status`.match(/working directory clean/)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require "mobi_check_in/version"
|
2
|
+
require "mobi_check_in/git"
|
3
|
+
require "yaml"
|
4
|
+
|
5
|
+
module MobiCheckIn
|
6
|
+
def self.incremental options={}
|
7
|
+
pair_names = ""
|
8
|
+
story_number = ""
|
9
|
+
|
10
|
+
if Git.has_local_changes?
|
11
|
+
history_file = '/tmp/mobi_check_in_history.yml'
|
12
|
+
if File.exists?(history_file)
|
13
|
+
shove_history = YAML::load(File.open(history_file))["shove"]
|
14
|
+
pair_names = shove_history["pair"]
|
15
|
+
story_number = shove_history["story"]
|
16
|
+
end
|
17
|
+
|
18
|
+
begin
|
19
|
+
$stdout.write "Pair names (separated with '/') [#{pair_names}]: "
|
20
|
+
input = $stdin.gets.strip
|
21
|
+
pair_names = input unless input.empty?
|
22
|
+
end until !pair_names.empty?
|
23
|
+
|
24
|
+
begin
|
25
|
+
$stdout.write "Story number (NA) [#{story_number}]: "
|
26
|
+
input = $stdin.gets.strip
|
27
|
+
input = "MOBI-#{input}" if input =~ /^\d*$/
|
28
|
+
story_number = input unless input.empty?
|
29
|
+
end until !story_number.empty?
|
30
|
+
|
31
|
+
File.open(history_file, 'w') do |out|
|
32
|
+
YAML.dump({ "shove" => { "pair" => pair_names, "story" => story_number } }, out)
|
33
|
+
end
|
34
|
+
|
35
|
+
if story_number.delete("/").downcase == "na"
|
36
|
+
commit_message = ""
|
37
|
+
else
|
38
|
+
commit_message = "#{story_number} - #{pair_names} - "
|
39
|
+
end
|
40
|
+
|
41
|
+
author = "#{pair_names}"
|
42
|
+
|
43
|
+
system("git add -A") if options[:add]
|
44
|
+
system("EDITOR=vim git commit --author='#{author}' -e -m '#{commit_message}'")
|
45
|
+
else
|
46
|
+
puts "No local changes to commit."
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.pre_commit_tasks
|
52
|
+
if File::exists? '.mobi_check_in.yml'
|
53
|
+
file = File.read('.mobi_check_in.yml')
|
54
|
+
pre_commit_tasks = YAML::load(file)["pre_commit"]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.push_commits
|
59
|
+
puts "*******"
|
60
|
+
puts "About to push these changes:"
|
61
|
+
puts Git.local_commits
|
62
|
+
puts "*******"
|
63
|
+
puts "Shoving..."
|
64
|
+
push_command
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.push_command
|
68
|
+
if File::exists? '.mobi_check_in.yml'
|
69
|
+
system(YAML::load(File.read('.mobi_check_in.yml'))["push_command"]) || standard_push
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.standard_push
|
74
|
+
system("git push")
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.push_and_test
|
78
|
+
if pre_commit_tasks
|
79
|
+
if system(pre_commit_tasks)
|
80
|
+
push_commits
|
81
|
+
else
|
82
|
+
puts "Tests failed. Shove aborted."
|
83
|
+
exit(1)
|
84
|
+
end
|
85
|
+
else
|
86
|
+
push_commits
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'mobi_check_in/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "mobi_check_in"
|
8
|
+
gem.version = MobiCheckIn::VERSION
|
9
|
+
gem.authors = ["David Kormushoff"]
|
10
|
+
gem.email = ["kormie@gmail.com"]
|
11
|
+
gem.description = %q{A check in gem}
|
12
|
+
gem.summary = %q{A way to check in}
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mobi_check_in
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- David Kormushoff
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-04 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: A check in gem
|
15
|
+
email:
|
16
|
+
- kormie@gmail.com
|
17
|
+
executables:
|
18
|
+
- ci
|
19
|
+
- cic
|
20
|
+
- cii
|
21
|
+
extensions: []
|
22
|
+
extra_rdoc_files: []
|
23
|
+
files:
|
24
|
+
- .gitignore
|
25
|
+
- Gemfile
|
26
|
+
- LICENSE.txt
|
27
|
+
- README.md
|
28
|
+
- Rakefile
|
29
|
+
- bin/ci
|
30
|
+
- bin/cic
|
31
|
+
- bin/cii
|
32
|
+
- lib/mobi_check_in.rb
|
33
|
+
- lib/mobi_check_in/git.rb
|
34
|
+
- lib/mobi_check_in/version.rb
|
35
|
+
- mobi_check_in.gemspec
|
36
|
+
homepage: ''
|
37
|
+
licenses: []
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options: []
|
40
|
+
require_paths:
|
41
|
+
- lib
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
requirements: []
|
55
|
+
rubyforge_project:
|
56
|
+
rubygems_version: 1.8.24
|
57
|
+
signing_key:
|
58
|
+
specification_version: 3
|
59
|
+
summary: A way to check in
|
60
|
+
test_files: []
|