mistilteinn 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +15 -12
- data/bin/mistilteinn +0 -1
- data/lib/mistilteinn/cli/command.rb +1 -1
- data/lib/mistilteinn/cli/edit.rb +11 -0
- data/lib/mistilteinn/cli/init.rb +2 -2
- data/lib/mistilteinn/git.rb +2 -2
- data/lib/mistilteinn/ticket/git_config.rb +63 -121
- data/lib/mistilteinn/version.rb +1 -1
- data/mistilteinn.gemspec +4 -1
- metadata +13 -19
- data/.gitignore +0 -7
- data/.mistilteinn/config.yaml +0 -9
- data/bin/.gitkeep +0 -0
- data/spec/.gitkeep +0 -0
data/README.markdown
CHANGED
@@ -8,27 +8,28 @@ OVERVIEW
|
|
8
8
|
Mistilteinn for shell is a comamnd to support a development style for
|
9
9
|
using git and redmine.
|
10
10
|
|
11
|
-
|
11
|
+
Prerequisites
|
12
12
|
------------------------------
|
13
13
|
|
14
14
|
* Ruby 1.8.7
|
15
15
|
* RubyGems 1.4.2 or later
|
16
16
|
* git subcommands https://github.com/mistilteinn/git-tools
|
17
|
+
* Git Hooks https://github.com/bleis-tift/Git-Hooks
|
17
18
|
|
18
19
|
Install
|
19
20
|
------------------------------
|
20
21
|
|
21
|
-
|
22
|
+
$ gem install mistilteinn
|
22
23
|
|
23
24
|
Setup for each project
|
24
25
|
------------------------------
|
25
26
|
|
26
27
|
To use mistilteinn, run `mistilteinn init` at each project dirctory.
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
$ cd /path/to/project
|
30
|
+
$ git init
|
31
|
+
$ mistilteinn init
|
32
|
+
$ vim .mistilteinn/config.yaml
|
32
33
|
|
33
34
|
Usage
|
34
35
|
------------------------------
|
@@ -37,24 +38,24 @@ Usage
|
|
37
38
|
|
38
39
|
Check if miltilteinn works:
|
39
40
|
|
40
|
-
|
41
|
+
$ mistilteinn self-check
|
41
42
|
|
42
43
|
### init
|
43
44
|
|
44
45
|
Initialize working directory for mistilteinn:
|
45
46
|
|
46
|
-
|
47
|
-
|
47
|
+
$ mistilteinn init
|
48
|
+
$ vim .mistilteinn/config.yaml
|
48
49
|
|
49
50
|
### list ticket
|
50
51
|
|
51
|
-
|
52
|
+
$ mistilteinn list
|
52
53
|
|
53
54
|
### create ticket
|
54
55
|
|
55
|
-
|
56
|
+
$ mistilteinn create hoge
|
56
57
|
|
57
|
-
Build(
|
58
|
+
Build(developer only)
|
58
59
|
------------------------------
|
59
60
|
|
60
61
|
### Prerequires
|
@@ -84,6 +85,8 @@ AUTHOR
|
|
84
85
|
|
85
86
|
* @mzp
|
86
87
|
* @suer
|
88
|
+
* @shimomura1004
|
89
|
+
* @mallowlabs
|
87
90
|
|
88
91
|
License
|
89
92
|
-----------------------
|
data/bin/mistilteinn
CHANGED
data/lib/mistilteinn/cli/init.rb
CHANGED
data/lib/mistilteinn/git.rb
CHANGED
@@ -1,156 +1,98 @@
|
|
1
1
|
# -*- mode:ruby; coding:utf-8 -*-
|
2
2
|
require 'tempfile'
|
3
3
|
|
4
|
+
class Tempfile
|
5
|
+
def edit(editor=nil)
|
6
|
+
mtime_before_edit = self.mtime
|
7
|
+
self.close
|
8
|
+
system "#{editor || ENV["EDITOR"]} #{self.path}"
|
9
|
+
self.open
|
10
|
+
return self.mtime != mtime_before_edit
|
11
|
+
end
|
12
|
+
def content=(content)
|
13
|
+
self.rewind
|
14
|
+
self.write content
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
4
18
|
module Mistilteinn
|
5
19
|
module Ticket
|
6
|
-
class
|
7
|
-
def initialize(
|
8
|
-
@config = config_hash
|
9
|
-
@path = path
|
10
|
-
end
|
11
|
-
attr_reader :config
|
12
|
-
|
13
|
-
def has_key?(key)
|
14
|
-
@config.has_key?(key) || @config.has_key?(key.to_s)
|
15
|
-
end
|
16
|
-
|
17
|
-
def []=(*args)
|
18
|
-
assignment(args[0], args[1])
|
19
|
-
end
|
20
|
-
|
21
|
-
def [](key)
|
22
|
-
key = key.to_s if key.class == Symbol
|
23
|
-
method_missing(key)
|
20
|
+
class GitConfig
|
21
|
+
def initialize(config)
|
24
22
|
end
|
25
23
|
|
26
|
-
def
|
27
|
-
|
28
|
-
is_assignment = create_if_nil = false
|
29
|
-
if name[-1..-1] == '=' then
|
30
|
-
is_assignment = true
|
31
|
-
name.slice! -1
|
32
|
-
end
|
33
|
-
if name[-1..-1] == '_' then
|
34
|
-
create_if_nil = true
|
35
|
-
name.slice! -1
|
36
|
-
end
|
37
|
-
|
38
|
-
return assignment(name, args[0]) if is_assignment
|
39
|
-
|
40
|
-
config_object = get_config_object(@path+[name.to_s])
|
41
|
-
return nil if config_object.config.empty? and not create_if_nil
|
42
|
-
|
43
|
-
if config_object.config.class == Hash then
|
44
|
-
config_object
|
45
|
-
else
|
46
|
-
config_object.config
|
47
|
-
end
|
24
|
+
def check
|
25
|
+
'ok'
|
48
26
|
end
|
49
27
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
else
|
57
|
-
@config[path[-1]] = {}
|
58
|
-
@@config_objects[path] = Config::new({}, path)
|
28
|
+
def tickets
|
29
|
+
last_ticket_id = ::Mistilteinn::Git.config "ticket.last"
|
30
|
+
(1...last_ticket_id.to_i).map do |id|
|
31
|
+
subject = ::Mistilteinn::Git.config "ticket.id/#{id}.subject"
|
32
|
+
status = ::Mistilteinn::Git.config "ticket.id/#{id}.status"
|
33
|
+
::Mistilteinn::Ticket::Entry.new(id, subject, status)
|
59
34
|
end
|
60
35
|
end
|
61
36
|
|
62
|
-
def
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
elems = path.split '.'
|
72
|
-
elems[0..-2].each do |path|
|
73
|
-
subconfig[path] = {} if subconfig[path].nil?
|
74
|
-
subconfig = subconfig[path]
|
75
|
-
end
|
76
|
-
subconfig[elems[-1]] = value
|
77
|
-
end
|
78
|
-
Config::new(config_hash, [])
|
79
|
-
end
|
37
|
+
def create(title = "")
|
38
|
+
tmpfile = Tempfile.new 'tmp'
|
39
|
+
tmpfile.content = ticket_format({
|
40
|
+
:subject => title,
|
41
|
+
:author => ::Mistilteinn::Git::config("user.name"),
|
42
|
+
:date => Time.now,
|
43
|
+
:status => "new"
|
44
|
+
})
|
45
|
+
tmpfile.edit default_editor
|
80
46
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
end
|
85
|
-
end
|
47
|
+
ticket_id = (::Mistilteinn::Git.config("ticket.last") || "1").to_i
|
48
|
+
issue_ticket(tmpfile, ticket_id)
|
49
|
+
::Mistilteinn::Git.config("ticket.last", (ticket_id+1).to_s)
|
86
50
|
|
87
|
-
|
88
|
-
%x(git config #{name} "#{value}")
|
51
|
+
tmpfile.unlink
|
89
52
|
end
|
90
53
|
|
91
|
-
def
|
92
|
-
|
93
|
-
|
94
|
-
|
54
|
+
def edit(ticket_id)
|
55
|
+
tmpfile = Tempfile.new 'tmp'
|
56
|
+
tmpfile.content = ticket_format({
|
57
|
+
:subject => ::Mistilteinn::Git.config("ticket.id/#{ticket_id}.subject"),
|
58
|
+
:author => ::Mistilteinn::Git.config("ticket.id/#{ticket_id}.author"),
|
59
|
+
:date => ::Mistilteinn::Git.config("ticket.id/#{ticket_id}.date"),
|
60
|
+
:status => ::Mistilteinn::Git.config("ticket.id/#{ticket_id}.status"),
|
61
|
+
:description => ::Mistilteinn::Git.config("ticket.id/#{ticket_id}.description")
|
62
|
+
})
|
63
|
+
modified = tmpfile.edit default_editor
|
95
64
|
|
96
|
-
|
97
|
-
class ConfigError < StandardError; end
|
65
|
+
issue_ticket(tmpfile, ticket_id) if modified
|
98
66
|
|
99
|
-
|
100
|
-
@config = Config::init
|
67
|
+
tmpfile.unlink
|
101
68
|
end
|
102
69
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
data = @config.ticket["id/#{id}"]
|
107
|
-
::Mistilteinn::Ticket::Entry.new(id, data.subject, data.status)
|
108
|
-
end
|
70
|
+
private
|
71
|
+
def default_editor
|
72
|
+
::Mistilteinn::Git.config "core.editor"
|
109
73
|
end
|
110
74
|
|
111
|
-
def
|
112
|
-
|
113
|
-
Subject: #{
|
114
|
-
Author: #{
|
115
|
-
Date: #{
|
116
|
-
Status:
|
75
|
+
def ticket_format(data = {})
|
76
|
+
<<END
|
77
|
+
Subject: #{data[:subject]}
|
78
|
+
Author: #{data[:author]}
|
79
|
+
Date: #{data[:date]}
|
80
|
+
Status: #{data[:status]}
|
117
81
|
Description: |-
|
118
|
-
|
82
|
+
#{data[:description]}
|
119
83
|
END
|
84
|
+
end
|
120
85
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
ticket = @config.ticket
|
125
|
-
ticketNo = (ticket.ticketno || "1").to_i
|
126
|
-
|
86
|
+
def issue_ticket(datafile, ticket_id)
|
87
|
+
File::open(datafile.path) do |f|
|
127
88
|
YAML.load_documents(f) do |yaml|
|
128
89
|
yaml.each do |key, value|
|
129
|
-
ticket
|
90
|
+
::Mistilteinn::Git.config("ticket.id/#{ticket_id}.#{key}", "\"#{value}\"")
|
130
91
|
end
|
131
92
|
end
|
132
|
-
ticket.ticketno = (ticketNo+1).to_s
|
133
93
|
end
|
134
94
|
end
|
135
95
|
|
136
|
-
def edit(id)
|
137
|
-
end
|
138
|
-
|
139
|
-
private
|
140
|
-
def editTempFile(initialString, &proc)
|
141
|
-
tmp = Tempfile.new("tmp")
|
142
|
-
tmp.write initialString
|
143
|
-
tmp.close
|
144
|
-
|
145
|
-
editor = @config.core_.editor || ENV["EDITOR"]
|
146
|
-
system "#{editor} #{tmp.path}"
|
147
|
-
File.open(tmp.path) do |f|
|
148
|
-
modified = f.read != initialString
|
149
|
-
f.rewind
|
150
|
-
proc.call(f, modified)
|
151
|
-
end
|
152
|
-
tmp.unlink
|
153
|
-
end
|
154
96
|
end
|
155
97
|
end
|
156
98
|
end
|
data/lib/mistilteinn/version.rb
CHANGED
data/mistilteinn.gemspec
CHANGED
@@ -9,7 +9,10 @@ Gem::Specification.new do |gem|
|
|
9
9
|
gem.homepage = "https://github.com/mistilteinn/mistilteinn-shell"
|
10
10
|
|
11
11
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
-
|
12
|
+
exclude_from_gem = File::read('.excluded_from_gem').split("\n")
|
13
|
+
gem.files = `git ls-files`.split("\n").reject do |file|
|
14
|
+
exclude_from_gem.include? file
|
15
|
+
end
|
13
16
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
17
|
gem.name = "mistilteinn"
|
15
18
|
gem.require_paths = ["lib"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mistilteinn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-03-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
16
|
-
requirement: &
|
16
|
+
requirement: &78282030 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *78282030
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: subcommand
|
27
|
-
requirement: &
|
27
|
+
requirement: &78281770 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *78281770
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &78281510 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *78281510
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rake
|
49
|
-
requirement: &
|
49
|
+
requirement: &78281240 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *78281240
|
58
58
|
description: Mistilteinn is a command to support a development with git and redmine.
|
59
59
|
email:
|
60
60
|
- mzp.ppp@gmail.com
|
@@ -63,17 +63,15 @@ executables:
|
|
63
63
|
extensions: []
|
64
64
|
extra_rdoc_files: []
|
65
65
|
files:
|
66
|
-
- .gitignore
|
67
|
-
- .mistilteinn/config.yaml
|
68
66
|
- .rspec
|
69
67
|
- Gemfile
|
70
68
|
- README.markdown
|
71
69
|
- Rakefile
|
72
|
-
- bin/.gitkeep
|
73
70
|
- bin/mistilteinn
|
74
71
|
- lib/mistilteinn/cli.rb
|
75
72
|
- lib/mistilteinn/cli/command.rb
|
76
73
|
- lib/mistilteinn/cli/create.rb
|
74
|
+
- lib/mistilteinn/cli/edit.rb
|
77
75
|
- lib/mistilteinn/cli/hooks/commit-msg
|
78
76
|
- lib/mistilteinn/cli/hooks/common.sh
|
79
77
|
- lib/mistilteinn/cli/hooks/pre-commit
|
@@ -92,7 +90,6 @@ files:
|
|
92
90
|
- lib/mistilteinn/ticket/redmine.rb
|
93
91
|
- lib/mistilteinn/version.rb
|
94
92
|
- mistilteinn.gemspec
|
95
|
-
- spec/.gitkeep
|
96
93
|
- spec/config_spec.rb
|
97
94
|
- spec/spec_helper.rb
|
98
95
|
- spec/ticket/redmine_spec.rb
|
@@ -116,11 +113,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
113
|
version: '0'
|
117
114
|
requirements: []
|
118
115
|
rubyforge_project:
|
119
|
-
rubygems_version: 1.8.
|
116
|
+
rubygems_version: 1.8.17
|
120
117
|
signing_key:
|
121
118
|
specification_version: 3
|
122
119
|
summary: Mistilteinn is a command to support a development with git and redmine.
|
123
|
-
test_files:
|
124
|
-
- spec/config_spec.rb
|
125
|
-
- spec/spec_helper.rb
|
126
|
-
- spec/ticket/redmine_spec.rb
|
120
|
+
test_files: []
|
data/.gitignore
DELETED
data/.mistilteinn/config.yaml
DELETED
data/bin/.gitkeep
DELETED
File without changes
|
data/spec/.gitkeep
DELETED
File without changes
|