gitan 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,8 +1,21 @@
1
1
  = Gitan changelog
2
2
 
3
+ == Master for 0.0.3
4
+
5
+ == Version 0.0.2
6
+ * Bugfix of to_be_pushed; to be false just after git pull.
7
+ * add bin/gitan
8
+ * add gitan subcommand, gitan status, alternatively to bin/gitanstatus
9
+ * add gitan subcommand, gitan heads
10
+ * add gitan subcommand, gitan commit
11
+ * add gitan subcommand, gitan push
12
+ * add gitan subcommand, gitan pull
13
+ * add --remote option to 'gitan status'
14
+ * add --all and --explain options to gitan status
15
+
3
16
  == Version 0.0.1
4
- * Small bugfix for executable bin/gitanstatus
17
+ * small bugfix for executable bin/gitanstatus
5
18
 
6
19
  == Version 0.0.0
7
- * Add Gitan::Repo
8
- * Add bin/gitanstatus
20
+ * add Gitan::Repo
21
+ * add bin/gitanstatus
data/README.rdoc CHANGED
@@ -1,6 +1,23 @@
1
1
  = gitan
2
2
 
3
- Description goes here.
3
+ This gem provides some commands to manage multiple git repositories.
4
+ 'gitan status' shows status of every git repository.
5
+ - multiple branch?
6
+ - changes to be staged?
7
+ - changes to be commited?
8
+ - changes to be pushed?
9
+ - updates on remote repository? (when --remote option is used)
10
+
11
+ 'gitan commit' commits on all git repositories that has changes to be commited.
12
+ 'gitan push' pushes on all git repositories that has changes to be pushed.
13
+ 'gitan pull' pulles on all git repositories that has updates on remote repository.
14
+ The repositories that have no changes are ignored.
15
+
16
+ == Installation
17
+ If you want to use --remote options, install gitan at remote host and enable to execute 'gitan heads'.
18
+
19
+ == Usage
20
+ Execute 'gitan --help'.
4
21
 
5
22
  == Contributing to gitan
6
23
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
data/bin/gitan ADDED
@@ -0,0 +1,165 @@
1
+ #! /usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ #gitan heads
5
+ # Show hash value of every git repository.
6
+ #
7
+ #gitan status
8
+ # Show status of every git working trees.
9
+ # Confirm the command 'git rev-parse FETCH_HEAD' show a hash value.
10
+ # If not, you should execute 'git pull'
11
+ #
12
+ #gitan commit
13
+ # Commit every working tree that has changes to be be commited.
14
+ #
15
+ #gitan push
16
+ # Commit every working tree that has changes to be pushed.
17
+ #
18
+ #gitan pull
19
+ # Pull every working tree that has update on remote.
20
+
21
+ require "optparse"
22
+ require "yaml"
23
+ require "pp"
24
+ require "gitan"
25
+
26
+ def show_usage
27
+ puts <<-HERE
28
+ USAGE
29
+ gitan heads [path]"
30
+ gitan status [path] [-r remote_dir]"
31
+ gitan commit [path] [-a arguments]"
32
+ gitan push [path] [-a arguments]"
33
+ gitan pull [path] [-a arguments] [-r remote_dir]"
34
+
35
+ Default value of 'path' is ~/git.
36
+
37
+ Examples:
38
+ gitan heads /home/git
39
+ gitan status -r example.com:/home/git
40
+ gitan commit --argument='-am "commit message"'
41
+ gitan push -a "origin master"
42
+ gitan pull ~/git -r example.com:/home/git -a "origin master"
43
+ HERE
44
+ end
45
+
46
+ def add_remote_option
47
+ OPTION_PARSER.on("-r remote_dir", "--remote=dir", "with remote info"){ |remote_dir|
48
+ server, path = remote_dir.split(":")
49
+ OPTIONS[:remote] = Gitan.remote_heads(server, path)
50
+ }
51
+ end
52
+
53
+ def add_argument_option
54
+ OPTION_PARSER.on("-a str", "--arguments=str", "supply argument to command"){ |str|
55
+ OPTIONS[:argument] = str
56
+ }
57
+ end
58
+
59
+ def repositories(remote_heads = {})
60
+ git_dir = ENV["HOME"] + "/git"
61
+ git_dir = File::expand_path(ARGV[0]) if ARGV[0]
62
+
63
+
64
+ dirs = Dir.glob(git_dir + "/*").sort.map do |path|
65
+ if File.directory? path
66
+ remote_head = nil
67
+ remote_head = OPTIONS[:remote][File.basename(path)] if OPTIONS[:remote]
68
+ Gitan::Repo.new(path, remote_head)
69
+ else
70
+ nil
71
+ end
72
+ end
73
+ dirs.select{|dir| dir}
74
+ end
75
+
76
+ def execute(path, command)
77
+ print "#{path}: "
78
+ Dir.chdir path
79
+ puts command
80
+ system command unless OPTIONS[:debug]
81
+ end
82
+
83
+ def status
84
+ add_remote_option
85
+ OPTION_PARSER.on("-a", "--all", "show all repositories."){ OPTIONS[:all] = true}
86
+ OPTION_PARSER.on("-e", "--explain", "show explanation for abbreviation."){ OPTIONS[:explain] = true}
87
+ OPTION_PARSER.parse!(ARGV)
88
+
89
+ repos = repositories
90
+ unless OPTIONS[:all]
91
+ repos = repos.select do |repo|
92
+ result = false
93
+ result = true if repo.multiple_branch?
94
+ result = true if repo.to_be_staged?
95
+ result = true if repo.to_be_commited?
96
+ result = true if repo.to_be_pushed?
97
+ result = true if (OPTIONS[:remote] && repo.to_be_pulled?)
98
+ result
99
+ end
100
+ end
101
+
102
+ Gitan::Repo.show_abbreviation if OPTIONS[:explain]
103
+ repos.each do |repo|
104
+ puts repo.short_status
105
+ end
106
+ end
107
+
108
+ def heads
109
+ results = {}
110
+ repositories.each do |repo|
111
+ results[repo.path] = repo.head
112
+ end
113
+ YAML.dump(results, $stdout)
114
+ end
115
+
116
+ def commit
117
+ add_argument_option
118
+ OPTION_PARSER.parse!(ARGV)
119
+ repositories.select {|repo| repo.to_be_commited?}.each do |repo|
120
+ execute(repo.path, "git commit #{OPTIONS[:argument]}")
121
+ end
122
+ end
123
+
124
+ def push
125
+ add_argument_option
126
+ OPTION_PARSER.parse!(ARGV)
127
+
128
+ repositories.select {|repo| repo.to_be_pushed?}.each do |repo|
129
+ execute(repo.path, "git push #{OPTIONS[:argument]}")
130
+ end
131
+ end
132
+
133
+ def pull
134
+ add_remote_option
135
+ add_argument_option
136
+ OPTION_PARSER.parse!(ARGV)
137
+
138
+ repositories.select {|repo| repo.to_be_pulled?}.each do |repo|
139
+ execute(repo.path, "git pull #{OPTIONS[:argument]}")
140
+ end
141
+ end
142
+
143
+ ##main
144
+ OPTIONS = {}
145
+ OPTION_PARSER = OptionParser.new
146
+ OPTION_PARSER.on("-d", "--debug", "debug mode."){OPTIONS[:debug] = true}
147
+ command = ARGV.shift
148
+
149
+ case command
150
+ when "status"
151
+ status
152
+ when "heads"
153
+ heads
154
+ when "commit"
155
+ commit
156
+ when "push"
157
+ push
158
+ when "pull"
159
+ pull
160
+ when "--help"
161
+ show_usage
162
+ else
163
+ puts "Unknown command: #{command}"
164
+ show_usage
165
+ end
data/gitan.gemspec CHANGED
@@ -5,14 +5,14 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "gitan"
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["ippei94da"]
12
- s.date = "2013-09-05"
12
+ s.date = "2013-09-09"
13
13
  s.description = "This gem provides some commands to manage multiple git repositories."
14
14
  s.email = "ippei94da@gmail.com"
15
- s.executables = ["gitanstatus"]
15
+ s.executables = ["gitan"]
16
16
  s.extra_rdoc_files = [
17
17
  "LICENSE.txt",
18
18
  "README.rdoc"
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
25
25
  "README.rdoc",
26
26
  "Rakefile",
27
27
  "VERSION",
28
- "bin/gitanstatus",
28
+ "bin/gitan",
29
29
  "gitan.gemspec",
30
30
  "lib/gitan.rb",
31
31
  "lib/gitan/repo.rb",
data/lib/gitan/repo.rb CHANGED
@@ -1,12 +1,21 @@
1
1
  #
2
2
  class Gitan::Repo
3
+ attr_reader :path
3
4
 
4
5
  def self.show_abbreviation(io = $stdout)
5
- io.puts "==== B: multiple branches, S: to be staged, C: to be commited, P: to be pushed."
6
+ #io.puts "==== B: multiple branches, S: to be staged, C: to be commited, P: to be pushed, L: to be pulled."
7
+ io.puts "Abbreviations:"
8
+ io.puts " L: to be pulled."
9
+ io.puts " B: multiple branches"
10
+ io.puts " S: to be staged"
11
+ io.puts " C: to be commited"
12
+ io.puts " P: to be pushed"
13
+ io.puts "========================================"
6
14
  end
7
15
 
8
- def initialize(path)
16
+ def initialize(path, remote_head = false)
9
17
  @path = path
18
+ @remote_head = remote_head
10
19
  end
11
20
 
12
21
  #Return short status as String. E.g,
@@ -17,6 +26,9 @@ class Gitan::Repo
17
26
  # C: to be commited
18
27
  # P: to be pushed
19
28
  def short_status
29
+ l = " "
30
+ l = "L" if @remote_head && to_be_pulled?
31
+
20
32
  b = " "
21
33
  b = "B" if multiple_branch?
22
34
 
@@ -29,7 +41,7 @@ class Gitan::Repo
29
41
  p = " "
30
42
  p = "P" if to_be_pushed?
31
43
 
32
- return (b + s + c + p + " " + @path)
44
+ return (l + b + s + c + p + " " + File.basename(@path))
33
45
  end
34
46
 
35
47
  def multiple_branch?
@@ -39,28 +51,45 @@ class Gitan::Repo
39
51
 
40
52
  #Return true if working tree has untracked changes.
41
53
  def to_be_staged?
42
- lines = command_output_lines("git status -s")
43
- return lines.select {|line| line =~ /^\?\?/} != []
54
+ lines = command_output_lines("git status --porcelain")
55
+ result = false
56
+ lines.each do |line|
57
+ result = true if line =~ /^\?\? /
58
+ result = true if line =~ /^ . /
59
+ end
60
+ return result
44
61
  end
45
62
 
46
63
  #Return true if working tree has changes on stage index.
47
64
  def to_be_commited?
48
- lines = command_output_lines("git status -s")
65
+ lines = command_output_lines("git status --porcelain")
49
66
  return lines.select {|line| line =~ /^[^\?]/} != []
50
67
  end
51
68
 
52
69
  #Return true if working tree has change which is commited but not pushed.
53
70
  def to_be_pushed?
54
- head = command_output_lines("git rev-parse HEAD")[0]
71
+ result = true
72
+
55
73
  remote_lines = command_output_lines("git rev-parse --remotes")
56
- return (! remote_lines.include?(head))
74
+ result = false if remote_lines.include?(head)
75
+
76
+ fetch_head = command_output_lines("git rev-parse FETCH_HEAD")[0]
77
+ result = false if head == fetch_head
78
+
79
+ return result
57
80
  end
58
81
 
59
- private
82
+ def head
83
+ command_output_lines("git rev-parse HEAD")[0]
84
+ end
85
+
86
+ #Return true if the working tree has un-pulled changes on remote.
87
+ def to_be_pulled?
88
+ lines = command_output_lines('git log --pretty=format:"%H"')
89
+ return ! lines.include?(@remote_head)
90
+ end
60
91
 
61
- #def short_status_lines
62
- # `git status -s`.split("\n")
63
- #end
92
+ private
64
93
 
65
94
  def command_output_lines(str)
66
95
  Dir.chdir @path
data/lib/gitan.rb CHANGED
@@ -1,5 +1,19 @@
1
1
  module Gitan; end
2
2
 
3
3
  require "pp"
4
+ require "yaml"
4
5
  #require "grit"
5
6
  require "gitan/repo.rb"
7
+
8
+ module Gitan
9
+
10
+ #Return heads in remote host.
11
+ def self.remote_heads(server, path)
12
+ results = {}
13
+ YAML.load(`ssh #{server} gitan heads #{path}`).each do |repo_path, head|
14
+ repo_name = File.basename(repo_path).sub(/\.git$/, "")
15
+ results[repo_name] = head
16
+ end
17
+ return results
18
+ end
19
+ end
@@ -2,14 +2,7 @@ gem "test-unit"
2
2
  require "test/unit"
3
3
  require "gitan"
4
4
 
5
-
6
- #class GritRepoDummy
7
- # attr_accessor :status
8
- # def initialize(status)
9
- # @status = status
10
- # end
11
- #end
12
- #
5
+ #class GritRepoDummy # attr_accessor :status # def initialize(status) # @status = status # end #end #
13
6
  #class GritRepoStatusDummy
14
7
  # attr_accessor :changed
15
8
  # attr_accessor :added
@@ -44,85 +37,137 @@ class TestRepo < Test::Unit::TestCase
44
37
  def setup
45
38
  outputs = {
46
39
  "git branch" => ["* master"],
47
- "git status -s" => [],
48
- "git rev-parse HEAD" => ["b4a9cab36b51cc8ca9b9a67d4b7c82abf6f02df4"],
40
+ "git status --porcelain" => [],
41
+ "git rev-parse HEAD" => ["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"],
42
+ "git rev-parse FETCH_HEAD" => ["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"],
49
43
  "git rev-parse --remotes" => [
50
- "b4a9cab36b51cc8ca9b9a67d4b7c82abf6f02df4",
51
- "d37ebd5948c87c142cf52572c44f032896879ec9",
44
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
45
+ "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
52
46
  ],
53
47
  }
54
- @r00 = Gitan::Repo.new("r00")
48
+ @r00 = Gitan::Repo.new("/home/git/r00")
55
49
  @r00.set_outputs(outputs)
56
50
 
57
51
  outputs = {
58
52
  "git branch" => ["* master", " tmp"],
59
- "git status -s" => [
53
+ "git status --porcelain" => [
60
54
  " M Gemfile",
61
55
  "AM bin/gitanstatus",
62
56
  "?? test/gitan/",
63
57
  ],
64
- "git rev-parse HEAD" => ["b4a9cab36b51cc8ca9b9a67d4b7c82abf6f02df4"],
58
+ "git rev-parse HEAD" => ["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"],
59
+ "git rev-parse FETCH_HEAD" => ["dddddddddddddddddddddddddddddddddddddddd"],
65
60
  "git rev-parse --remotes" => [
66
- "6671b434a3ed6414cab0c676a90c575bbb03d9da",
67
- "d37ebd5948c87c142cf52572c44f032896879ec9",
61
+ "cccccccccccccccccccccccccccccccccccccccc",
62
+ "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
68
63
  ],
69
64
  }
70
- @r01 = Gitan::Repo.new("r01")
65
+ @r01 = Gitan::Repo.new("/home/git/r01")
71
66
  @r01.set_outputs(outputs)
72
67
 
73
68
  outputs = {
74
69
  "git branch" => ["* master", " tmp"],
75
- "git status -s" => [
70
+ "git status --porcelain" => [
76
71
  "?? test/gitan/",
77
72
  ],
78
- "git rev-parse HEAD" => ["b4a9cab36b51cc8ca9b9a67d4b7c82abf6f02df4"],
73
+ "git rev-parse HEAD" => ["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"],
74
+ "git rev-parse FETCH_HEAD" => ["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"],
79
75
  "git rev-parse --remotes" => [
80
- "6671b434a3ed6414cab0c676a90c575bbb03d9da",
81
- "b4a9cab36b51cc8ca9b9a67d4b7c82abf6f02df4",
76
+ "cccccccccccccccccccccccccccccccccccccccc",
77
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
82
78
  ],
83
79
  }
84
- @r02 = Gitan::Repo.new("r02")
80
+ @r02 = Gitan::Repo.new("/home/git/r02")
85
81
  @r02.set_outputs(outputs)
86
82
 
87
83
  outputs = {
88
84
  "git branch" => ["* master"],
89
- "git status -s" => [],
90
- "git rev-parse HEAD" => ["b4a9cab36b51cc8ca9b9a67d4b7c82abf6f02df4"],
85
+ "git status --porcelain" => [],
86
+ "git rev-parse HEAD" => ["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"],
87
+ "git rev-parse FETCH_HEAD" => ["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"],
91
88
  "git rev-parse --remotes" => [
92
- "b4a9cab36b51cc8ca9b9a67d4b7c82abf6f02df4",
89
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
93
90
  ],
94
91
  }
95
- @r03 = Gitan::Repo.new("r00")
92
+ @r03 = Gitan::Repo.new("/home/git/r00")
96
93
  @r03.set_outputs(outputs)
97
94
 
95
+ outputs = {
96
+ "git branch" => ["* master"],
97
+ "git status --porcelain" => [],
98
+ "git rev-parse HEAD" => ["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"],
99
+ "git rev-parse FETCH_HEAD" => ["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"],
100
+ "git rev-parse --remotes" => [
101
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
102
+ "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
103
+ ],
104
+ 'git log --pretty=format:"%H"' => [
105
+ 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
106
+ 'ffffffffffffffffffffffffffffffffffffffff',
107
+ '0000000000000000000000000000000000000000',
108
+ ]
109
+ }
110
+ @r04 = Gitan::Repo.new("/home/git/r04","aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
111
+ @r04.set_outputs(outputs)
112
+
113
+ @r05 = Gitan::Repo.new("/home/git/r05","eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee")
114
+ @r05.set_outputs(outputs)
115
+
116
+ outputs = {
117
+ "git branch" => ["* master", " tmp"],
118
+ "git status --porcelain" => [
119
+ " M Gemfile",
120
+ "AM bin/gitanstatus",
121
+ "?? test/gitan/",
122
+ ],
123
+ "git rev-parse HEAD" => ["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"],
124
+ "git rev-parse FETCH_HEAD" => ["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"],
125
+ "git rev-parse --remotes" => [
126
+ "cccccccccccccccccccccccccccccccccccccccc",
127
+ "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
128
+ ],
129
+ }
130
+ @r06 = Gitan::Repo.new("/home/git/r01")
131
+ @r06.set_outputs(outputs)
132
+
98
133
  end
99
134
 
100
135
  def test_to_be_staged?
101
136
  assert_equal(false, @r00.to_be_staged?)
102
137
  assert_equal(true , @r01.to_be_staged?)
103
138
 
104
- @r00.outputs["git status -s"] = [
105
- "?? test/gitan/",
106
- ]
139
+ @r00.outputs["git status --porcelain"] = [ "?? test/gitan/", ]
107
140
  assert_equal(true , @r00.to_be_staged?)
108
141
 
109
- @r00.outputs["git status -s"] = [
142
+ @r00.outputs["git status --porcelain"] = [ " M Gemfile", ]
143
+ assert_equal(true , @r00.to_be_staged?)
144
+
145
+ @r00.outputs["git status --porcelain"] = [ "M Gemfile", ]
146
+ assert_equal(false, @r00.to_be_staged?)
147
+
148
+ @r00.outputs["git status --porcelain"] = [
110
149
  " M Gemfile",
111
150
  "AM bin/gitanstatus",
112
151
  ]
113
- assert_equal(false, @r00.to_be_staged?)
152
+ assert_equal(true , @r00.to_be_staged?)
153
+
154
+ @r00.outputs["git status --porcelain"] = [
155
+ "?? Gemfile",
156
+ "A bin/gitanstatus",
157
+ ]
158
+ assert_equal(true , @r00.to_be_staged?)
114
159
  end
115
160
 
116
161
  def test_to_be_commited?
117
162
  assert_equal(false, @r00.to_be_commited?)
118
163
  assert_equal(true , @r01.to_be_commited?)
119
164
 
120
- @r00.outputs["git status -s"] = [
165
+ @r00.outputs["git status --porcelain"] = [
121
166
  "?? test/gitan/",
122
167
  ]
123
168
  assert_equal(false, @r00.to_be_commited?)
124
169
 
125
- @r00.outputs["git status -s"] = [
170
+ @r00.outputs["git status --porcelain"] = [
126
171
  " M Gemfile",
127
172
  "AM bin/gitanstatus",
128
173
  ]
@@ -132,16 +177,16 @@ class TestRepo < Test::Unit::TestCase
132
177
  def test_command_output_lines
133
178
  assert_equal(
134
179
  [
135
- "b4a9cab36b51cc8ca9b9a67d4b7c82abf6f02df4",
136
- "d37ebd5948c87c142cf52572c44f032896879ec9",
180
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
181
+ "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
137
182
  ],
138
183
  @r00.command_output_lines("git rev-parse --remotes")
139
184
  )
140
185
 
141
186
  assert_equal(
142
187
  [
143
- "6671b434a3ed6414cab0c676a90c575bbb03d9da",
144
- "d37ebd5948c87c142cf52572c44f032896879ec9",
188
+ "cccccccccccccccccccccccccccccccccccccccc",
189
+ "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
145
190
  ],
146
191
  @r01.command_output_lines("git rev-parse --remotes")
147
192
  )
@@ -151,6 +196,7 @@ class TestRepo < Test::Unit::TestCase
151
196
  assert_equal(false, @r00.to_be_pushed?)
152
197
  assert_equal(true , @r01.to_be_pushed?)
153
198
  assert_equal(false , @r03.to_be_pushed?)
199
+ assert_equal(false , @r06.to_be_pushed?)
154
200
  end
155
201
 
156
202
  def test_multiple_branch?
@@ -160,9 +206,22 @@ class TestRepo < Test::Unit::TestCase
160
206
  end
161
207
 
162
208
  def test_short_status
163
- assert_equal(" r00", @r00.short_status)
164
- assert_equal("BSCP r01", @r01.short_status)
165
- assert_equal("BS r02", @r02.short_status)
209
+ assert_equal(" r00", @r00.short_status)
210
+ assert_equal(" BSCP r01", @r01.short_status)
211
+ assert_equal(" BS r02", @r02.short_status)
212
+ assert_equal("L r04", @r04.short_status)
213
+ assert_equal(" r05", @r05.short_status)
166
214
  end
167
215
 
216
+ def test_head
217
+ assert_equal("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
218
+ @r00.head)
219
+ end
220
+
221
+ def test_to_be_pulled?
222
+ assert_equal(true , @r04.to_be_pulled?)
223
+ assert_equal(false, @r05.to_be_pulled?)
224
+ end
225
+
226
+
168
227
  end
data/test/test_gitan.rb CHANGED
@@ -9,10 +9,12 @@ require 'helper'
9
9
  #
10
10
  gem "test-unit"
11
11
  require "test/unit"
12
+ require "gitan"
13
+ require "pp"
12
14
 
13
- class SampleTest < Test::Unit::TestCase
14
- def test_foo
15
- #assert_equal(1,1)
16
- #assert_equal(1,2)
15
+ class TestGitan < Test::Unit::TestCase
16
+ def test_remote_heads
17
+ ##How should be tested?
18
+ #pp Gitan.remote_heads("localhost", "/home/git")
17
19
  end
18
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-05 00:00:00.000000000 Z
12
+ date: 2013-09-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rdoc
@@ -94,7 +94,7 @@ dependencies:
94
94
  description: This gem provides some commands to manage multiple git repositories.
95
95
  email: ippei94da@gmail.com
96
96
  executables:
97
- - gitanstatus
97
+ - gitan
98
98
  extensions: []
99
99
  extra_rdoc_files:
100
100
  - LICENSE.txt
@@ -107,7 +107,7 @@ files:
107
107
  - README.rdoc
108
108
  - Rakefile
109
109
  - VERSION
110
- - bin/gitanstatus
110
+ - bin/gitan
111
111
  - gitan.gemspec
112
112
  - lib/gitan.rb
113
113
  - lib/gitan/repo.rb
@@ -129,7 +129,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
129
129
  version: '0'
130
130
  segments:
131
131
  - 0
132
- hash: 640285007
132
+ hash: -792430867
133
133
  required_rubygems_version: !ruby/object:Gem::Requirement
134
134
  none: false
135
135
  requirements:
data/bin/gitanstatus DELETED
@@ -1,26 +0,0 @@
1
- #! /usr/bin/env ruby
2
-
3
- require "gitan"
4
-
5
- if ARGV.empty?
6
- git_dir = ENV["HOME"] + "/git"
7
- else
8
- git_dir = File::expand_path(ARGV[0])
9
- end
10
-
11
-
12
- Gitan::Repo.show_abbreviation($stdout)
13
-
14
- repos = {}
15
- Dir.glob(git_dir + "/*").sort.map do |path|
16
- next unless File.directory? path
17
- repo = Gitan::Repo.new(path)
18
- puts repo.short_status
19
- #pp dirname
20
- #begin
21
- # repos[File.basename file] = Gitan::Repo.new( Grit::Repo.new(file))
22
- #rescue Grit::InvalidGitRepositoryError
23
- # next
24
- #end
25
-
26
- end