rugged 0.17.0b1 → 0.17.0b2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -43,7 +43,7 @@ task :cover do
43
43
  end
44
44
 
45
45
  Rake::TestTask.new do |t|
46
- t.libs << 'lib'
46
+ t.libs << 'lib:test'
47
47
  t.pattern = 'test/**/*_test.rb'
48
48
  t.verbose = false
49
49
  end
@@ -42,7 +42,7 @@ const char *RUGGED_ERROR_NAMES[] = {
42
42
  "IndexerError", /* GITERR_INDEXER, */
43
43
  };
44
44
 
45
- #define RUGGED_ERROR_COUNT ((sizeof(RUGGED_ERROR_NAMES)/sizeof(RUGGED_ERROR_NAMES[0])))
45
+ #define RUGGED_ERROR_COUNT (int)((sizeof(RUGGED_ERROR_NAMES)/sizeof(RUGGED_ERROR_NAMES[0])))
46
46
 
47
47
  VALUE rb_mRugged;
48
48
  VALUE rb_eRuggedError;
@@ -67,7 +67,7 @@ static VALUE rb_git_hex_to_raw(VALUE self, VALUE hex)
67
67
  Check_Type(hex, T_STRING);
68
68
  rugged_exception_check(git_oid_fromstr(&oid, StringValueCStr(hex)));
69
69
 
70
- return rugged_str_ascii(oid.id, 20);
70
+ return rugged_str_ascii((const char *)oid.id, 20);
71
71
  }
72
72
 
73
73
  /*
@@ -90,7 +90,7 @@ static VALUE rb_git_raw_to_hex(VALUE self, VALUE raw)
90
90
  if (RSTRING_LEN(raw) != GIT_OID_RAWSZ)
91
91
  rb_raise(rb_eTypeError, "Invalid buffer size for an OID");
92
92
 
93
- git_oid_fromraw(&oid, RSTRING_PTR(raw));
93
+ git_oid_fromraw(&oid, (const unsigned char *)RSTRING_PTR(raw));
94
94
  git_oid_fmt(out, &oid);
95
95
 
96
96
  return rugged_str_new(out, 40, NULL);
@@ -80,7 +80,7 @@ static inline void rugged_set_owner(VALUE object, VALUE owner)
80
80
 
81
81
  static inline VALUE rugged_owner(VALUE object)
82
82
  {
83
- rb_iv_get(object, "@owner");
83
+ return rb_iv_get(object, "@owner");
84
84
  }
85
85
 
86
86
  extern void rugged_exception_raise(int errorcode);
@@ -105,15 +105,9 @@ static inline int rugged_parse_bool(VALUE boolean)
105
105
  # define rugged_str_new2(str, enc) rb_enc_str_new(str, strlen(str), enc)
106
106
  # define rugged_str_ascii(str, len) rb_enc_str_new(str, len, rb_ascii8bit_encoding());
107
107
 
108
- static VALUE rugged_str_repoenc(const char *str, long len, VALUE rb_repo)
109
- {
110
- VALUE rb_enc = rb_iv_get(rb_repo, "@encoding");
111
- return rb_enc_str_new(str, len, NIL_P(rb_enc) ? NULL : rb_to_encoding(rb_enc));
112
- }
113
108
  #else
114
109
  # define rugged_str_new(str, len, rb_enc) rb_str_new(str, len)
115
110
  # define rugged_str_new2(str, rb_enc) rb_str_new2(str)
116
- # define rugged_str_repoenc(str, len, repo) rb_str_new(str, len)
117
111
  # define rugged_str_ascii(str, len) rb_str_new(str, len)
118
112
  #endif
119
113
 
@@ -23,6 +23,7 @@
23
23
  */
24
24
 
25
25
  #include "rugged.h"
26
+ #include <ctype.h>
26
27
 
27
28
  extern VALUE rb_mRugged;
28
29
  extern VALUE rb_cRuggedObject;
@@ -173,7 +173,6 @@ static VALUE rb_git_commit_tree_oid_GET(VALUE self)
173
173
  {
174
174
  git_commit *commit;
175
175
  const git_oid *tree_oid;
176
- int error;
177
176
 
178
177
  Data_Get_Struct(self, git_commit, commit);
179
178
 
@@ -233,7 +232,6 @@ static VALUE rb_git_commit_parent_oids_GET(VALUE self)
233
232
  const git_oid *parent_oid;
234
233
  unsigned int n, parent_count;
235
234
  VALUE ret_arr;
236
- int error;
237
235
 
238
236
  Data_Get_Struct(self, git_commit, commit);
239
237
 
@@ -166,7 +166,6 @@ static VALUE rb_git_config_delete(VALUE self, VALUE rb_key)
166
166
  {
167
167
  git_config *config;
168
168
  int error;
169
- VALUE result;
170
169
 
171
170
  Data_Get_Struct(self, git_config, config);
172
171
  Check_Type(rb_key, T_STRING);
@@ -2,17 +2,17 @@
2
2
  * The MIT License
3
3
  *
4
4
  * Copyright (c) 2011 GitHub, Inc
5
- *
5
+ *
6
6
  * Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  * of this software and associated documentation files (the "Software"), to deal
8
8
  * in the Software without restriction, including without limitation the rights
9
9
  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
10
  * copies of the Software, and to permit persons to whom the Software is
11
11
  * furnished to do so, subject to the following conditions:
12
- *
12
+ *
13
13
  * The above copyright notice and this permission notice shall be included in
14
14
  * all copies or substantial portions of the Software.
15
- *
15
+ *
16
16
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
17
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
18
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -164,7 +164,7 @@ static git_otype class2otype(VALUE klass)
164
164
 
165
165
  if (klass == rb_cRuggedTree)
166
166
  return GIT_OBJ_TREE;
167
-
167
+
168
168
  return GIT_OBJ_BAD;
169
169
  }
170
170
 
@@ -207,6 +207,44 @@ VALUE rb_git_object_lookup(VALUE klass, VALUE rb_repo, VALUE rb_hex)
207
207
  return rugged_object_new(rb_repo, object);
208
208
  }
209
209
 
210
+ static VALUE rugged_object_rev_parse(VALUE klass, VALUE rb_repo, VALUE rb_spec, int as_obj)
211
+ {
212
+ git_object *object;
213
+ const char *spec;
214
+ int error;
215
+ git_repository *repo;
216
+ VALUE ret;
217
+
218
+ Check_Type(rb_spec, T_STRING);
219
+ spec = RSTRING_PTR(rb_spec);
220
+
221
+ if (!rb_obj_is_instance_of(rb_repo, rb_cRuggedRepo))
222
+ rb_raise(rb_eTypeError, "Expecting a Rugged Repository");
223
+
224
+ Data_Get_Struct(rb_repo, git_repository, repo);
225
+
226
+ error = git_revparse_single(&object, repo, spec);
227
+ rugged_exception_check(error);
228
+
229
+ if (as_obj) {
230
+ return rugged_object_new(rb_repo, object);
231
+ }
232
+
233
+ ret = rugged_create_oid(git_object_id(object));
234
+ git_object_free(object);
235
+ return ret;
236
+ }
237
+
238
+ VALUE rb_git_object_rev_parse(VALUE klass, VALUE rb_repo, VALUE rb_spec)
239
+ {
240
+ return rugged_object_rev_parse(klass, rb_repo, rb_spec, 1);
241
+ }
242
+
243
+ VALUE rb_git_object_rev_parse_oid(VALUE klass, VALUE rb_repo, VALUE rb_spec)
244
+ {
245
+ return rugged_object_rev_parse(klass, rb_repo, rb_spec, 0);
246
+ }
247
+
210
248
  static VALUE rb_git_object_equal(VALUE self, VALUE other)
211
249
  {
212
250
  git_object *a, *b;
@@ -247,6 +285,8 @@ void Init_rugged_object()
247
285
  {
248
286
  rb_cRuggedObject = rb_define_class_under(rb_mRugged, "Object", rb_cObject);
249
287
  rb_define_singleton_method(rb_cRuggedObject, "lookup", rb_git_object_lookup, 2);
288
+ rb_define_singleton_method(rb_cRuggedObject, "rev_parse", rb_git_object_rev_parse, 2);
289
+ rb_define_singleton_method(rb_cRuggedObject, "rev_parse_oid", rb_git_object_rev_parse_oid, 2);
250
290
  rb_define_singleton_method(rb_cRuggedObject, "new", rb_git_object_lookup, 2);
251
291
 
252
292
  rb_define_method(rb_cRuggedObject, "read_raw", rb_git_object_read_raw, 0);
@@ -2,17 +2,17 @@
2
2
  * The MIT License
3
3
  *
4
4
  * Copyright (c) 2011 GitHub, Inc
5
- *
5
+ *
6
6
  * Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  * of this software and associated documentation files (the "Software"), to deal
8
8
  * in the Software without restriction, including without limitation the rights
9
9
  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
10
  * copies of the Software, and to permit persons to whom the Software is
11
11
  * furnished to do so, subject to the following conditions:
12
- *
12
+ *
13
13
  * The above copyright notice and this permission notice shall be included in
14
14
  * all copies or substantial portions of the Software.
15
- *
15
+ *
16
16
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
17
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
18
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -35,7 +35,7 @@ VALUE rb_cRuggedTag;
35
35
  *
36
36
  * Return the +object+ pointed at by this tag, as a <tt>Rugged::Object</tt>
37
37
  * instance.
38
- *
38
+ *
39
39
  * tag.target #=> #<Rugged::Commit:0x108828918>
40
40
  */
41
41
  static VALUE rb_git_tag_target_GET(VALUE self)
@@ -61,13 +61,12 @@ static VALUE rb_git_tag_target_GET(VALUE self)
61
61
  * Return the oid pointed at by this tag, as a <tt>String</tt>
62
62
  * instance.
63
63
  *
64
- * tag.target #=> "2cb831a8aea28b2c1b9c63385585b864e4d3bad1"
64
+ * tag.target_oid #=> "2cb831a8aea28b2c1b9c63385585b864e4d3bad1"
65
65
  */
66
66
  static VALUE rb_git_tag_target_oid_GET(VALUE self)
67
67
  {
68
68
  git_tag *tag;
69
69
  const git_oid *target_oid;
70
- int error;
71
70
 
72
71
  Data_Get_Struct(self, git_tag, tag);
73
72
 
@@ -19,6 +19,14 @@
19
19
  */
20
20
  GIT_BEGIN_DECL
21
21
 
22
+ /**
23
+ * Parse a refspec string and create a refspec object
24
+ *
25
+ * @param refspec pointer to the refspec structure to be used
26
+ * @param str the refspec as a string
27
+ */
28
+ GIT_EXTERN(int) git_refspec_parse(git_refspec *refspec, const char *str);
29
+
22
30
  /**
23
31
  * Get the source specifier
24
32
  *
@@ -28,6 +28,8 @@ static int parse_ignore_file(
28
28
  GITERR_CHECK_ALLOC(match);
29
29
  }
30
30
 
31
+ match->flags = GIT_ATTR_FNMATCH_ALLOWSPACE;
32
+
31
33
  if (!(error = git_attr_fnmatch__parse(
32
34
  match, ignores->pool, context, &scan)))
33
35
  {
@@ -66,6 +66,7 @@ typedef int GIT_SOCKET;
66
66
  #else
67
67
 
68
68
  typedef SOCKET GIT_SOCKET;
69
+ struct timezone;
69
70
  extern struct tm * p_localtime_r (const time_t *timer, struct tm *result);
70
71
  extern struct tm * p_gmtime_r (const time_t *timer, struct tm *result);
71
72
  extern int p_gettimeofday(struct timeval *tv, struct timezone *tz);
@@ -718,6 +718,9 @@ static int repo_init_config(const char *git_dir, bool is_bare, bool is_reinit)
718
718
  SET_REPO_CONFIG(int32, "core.repositoryformatversion", GIT_REPO_VERSION);
719
719
  SET_REPO_CONFIG(bool, "core.filemode", is_chmod_supported(git_buf_cstr(&cfg_path)));
720
720
 
721
+ if (!is_bare)
722
+ SET_REPO_CONFIG(bool, "core.logallrefupdates", true);
723
+
721
724
  if (!is_reinit && is_filesystem_case_insensitive(git_dir))
722
725
  SET_REPO_CONFIG(bool, "core.ignorecase", true);
723
726
  /* TODO: what other defaults? */
@@ -13,8 +13,6 @@
13
13
 
14
14
  #include "git2.h"
15
15
 
16
- GIT_BEGIN_DECL
17
-
18
16
  typedef enum {
19
17
  REVPARSE_STATE_INIT,
20
18
  REVPARSE_STATE_CARET,
@@ -748,6 +746,3 @@ int git_revparse_single(git_object **out, git_repository *repo, const char *spec
748
746
  git_buf_free(&stepbuffer);
749
747
  return retcode;
750
748
  }
751
-
752
-
753
- GIT_END_DECL
@@ -169,14 +169,23 @@ static commit_object *commit_lookup(git_revwalk *walk, const git_oid *oid)
169
169
  return commit;
170
170
  }
171
171
 
172
+ static int commit_error(commit_object *commit, const char *msg)
173
+ {
174
+ char commit_oid[GIT_OID_HEXSZ + 1];
175
+ git_oid_fmt(commit_oid, &commit->oid);
176
+ commit_oid[GIT_OID_HEXSZ] = '\0';
177
+
178
+ giterr_set(GITERR_ODB, "Failed to parse commit %s - %s", commit_oid, msg);
179
+
180
+ return -1;
181
+ }
182
+
172
183
  static int commit_quick_parse(git_revwalk *walk, commit_object *commit, git_rawobj *raw)
173
184
  {
174
185
  const size_t parent_len = strlen("parent ") + GIT_OID_HEXSZ + 1;
175
-
176
186
  unsigned char *buffer = raw->data;
177
187
  unsigned char *buffer_end = buffer + raw->len;
178
188
  unsigned char *parents_start;
179
-
180
189
  int i, parents = 0;
181
190
  int commit_time;
182
191
 
@@ -207,21 +216,18 @@ static int commit_quick_parse(git_revwalk *walk, commit_object *commit, git_rawo
207
216
 
208
217
  commit->out_degree = (unsigned short)parents;
209
218
 
210
- if ((buffer = memchr(buffer, '\n', buffer_end - buffer)) == NULL) {
211
- giterr_set(GITERR_ODB, "Failed to parse commit. Object is corrupted");
212
- return -1;
213
- }
219
+ if ((buffer = memchr(buffer, '\n', buffer_end - buffer)) == NULL)
220
+ return commit_error(commit, "object is corrupted");
214
221
 
215
- buffer = memchr(buffer, '>', buffer_end - buffer);
216
- if (buffer == NULL) {
217
- giterr_set(GITERR_ODB, "Failed to parse commit. Can't find author");
218
- return -1;
219
- }
222
+ if ((buffer = memchr(buffer, '<', buffer_end - buffer)) == NULL ||
223
+ (buffer = memchr(buffer, '>', buffer_end - buffer)) == NULL)
224
+ return commit_error(commit, "malformed author information");
220
225
 
221
- if (git__strtol32(&commit_time, (char *)buffer + 2, NULL, 10) < 0) {
222
- giterr_set(GITERR_ODB, "Failed to parse commit. Can't parse commit time");
223
- return -1;
224
- }
226
+ while (*buffer == '>' || git__isspace(*buffer))
227
+ buffer++;
228
+
229
+ if (git__strtol32(&commit_time, (char *)buffer, NULL, 10) < 0)
230
+ return commit_error(commit, "cannot parse commit time");
225
231
 
226
232
  commit->time = (time_t)commit_time;
227
233
  commit->parsed = 1;
@@ -166,14 +166,14 @@ void test_repo_init__additional_templates(void)
166
166
  git_buf_free(&path);
167
167
  }
168
168
 
169
- static void assert_config_entry_on_init(const char *config_key, int expected_value)
169
+ static void assert_config_entry_on_init_bytype(const char *config_key, int expected_value, bool is_bare)
170
170
  {
171
171
  git_config *config;
172
172
  int current_value;
173
173
 
174
174
  cl_set_cleanup(&cleanup_repository, "config_entry");
175
175
 
176
- cl_git_pass(git_repository_init(&_repo, "config_entry/test.git", 1));
176
+ cl_git_pass(git_repository_init(&_repo, "config_entry/test.git", is_bare));
177
177
  git_repository_config(&config, _repo);
178
178
 
179
179
  if (expected_value >= 0) {
@@ -189,6 +189,14 @@ static void assert_config_entry_on_init(const char *config_key, int expected_val
189
189
  git_config_free(config);
190
190
  }
191
191
 
192
+ static void assert_config_entry_on_init(const char *config_key, int expected_value)
193
+ {
194
+ assert_config_entry_on_init_bytype(config_key, expected_value, true);
195
+ git_repository_free(_repo);
196
+
197
+ assert_config_entry_on_init_bytype(config_key, expected_value, false);
198
+ }
199
+
192
200
  void test_repo_init__detect_filemode(void)
193
201
  {
194
202
  #ifdef GIT_WIN32
@@ -233,3 +241,9 @@ void test_repo_init__reinit_doesnot_overwrite_ignorecase(void)
233
241
 
234
242
  git_config_free(config);
235
243
  }
244
+
245
+ void test_repo_init__sets_logAllRefUpdates_according_to_type_of_repository(void)
246
+ {
247
+ assert_config_entry_on_init_bytype("core.logallrefupdates", GIT_ENOTFOUND, true);
248
+ assert_config_entry_on_init_bytype("core.logallrefupdates", true, false);
249
+ }
@@ -131,3 +131,17 @@ void test_status_ignore__empty_repo_with_gitignore_rewrite(void)
131
131
  cl_assert(ignored);
132
132
  }
133
133
 
134
+ void test_status_ignore__ignore_pattern_contains_space(void)
135
+ {
136
+ unsigned int flags;
137
+ const mode_t mode = 0777;
138
+
139
+ g_repo = cl_git_sandbox_init("empty_standard_repo");
140
+ cl_git_rewritefile("empty_standard_repo/.gitignore", "foo bar.txt\n");
141
+
142
+ cl_git_pass(git_futils_mkdir_r("empty_standard_repo/foo", NULL, mode));
143
+ cl_git_mkfile("empty_standard_repo/foo/look-ma.txt", "I'm not going to be ignored!");
144
+
145
+ cl_git_pass(git_status_file(&flags, g_repo, "foo/look-ma.txt"));
146
+ cl_assert(flags == GIT_STATUS_WT_NEW);
147
+ }
@@ -2,7 +2,7 @@ module Rugged
2
2
  class Commit
3
3
 
4
4
  def inspect
5
- "#<Rugged::Commit:#{object_id} {message: #{message.inspect}, tree: #{tree.inspect}, parents: #{parent_ids}>"
5
+ "#<Rugged::Commit:#{object_id} {message: #{message.inspect}, tree: #{tree.inspect}, parents: #{parent_oids.inspect}>"
6
6
  end
7
7
 
8
8
  # The time when this commit was made effective. This is the same value
@@ -22,10 +22,6 @@ module Rugged
22
22
  :parents => parents,
23
23
  }
24
24
  end
25
-
26
- def parent_ids
27
- parents.map { |parent| parent.oid }
28
- end
29
25
 
30
26
  def modify(new_args, update_ref=nil)
31
27
  args = self.to_hash.merge(new_args)
@@ -47,6 +47,20 @@ module Rugged
47
47
  Rugged::Object.lookup(self, oid)
48
48
  end
49
49
 
50
+ # Look up an object by a revision string.
51
+ #
52
+ # Returns one of the four classes that inherit from Rugged::Object.
53
+ def rev_parse(spec)
54
+ Rugged::Object.rev_parse(self, spec)
55
+ end
56
+
57
+ # Look up an object by a revision string.
58
+ #
59
+ # Returns the oid of the matched object as a String
60
+ def rev_parse_oid(spec)
61
+ Rugged::Object.rev_parse_oid(self, spec)
62
+ end
63
+
50
64
  # Look up a single reference by name.
51
65
  #
52
66
  # Example:
@@ -1,3 +1,3 @@
1
1
  module Rugged
2
- Version = VERSION = '0.17.0b1'
2
+ Version = VERSION = '0.17.0b2'
3
3
  end
@@ -1,4 +1,4 @@
1
- require File.expand_path "../test_helper", __FILE__
1
+ require "test_helper"
2
2
 
3
3
  context "Rugged::Blob tests" do
4
4
  setup do
@@ -1,4 +1,4 @@
1
- require File.expand_path "../test_helper", __FILE__
1
+ require "test_helper"
2
2
 
3
3
  context "Rugged::Commit tests" do
4
4
  setup do
@@ -1,8 +1,8 @@
1
- require File.expand_path "../test_helper", __FILE__
1
+ require "test_helper"
2
2
 
3
3
  context "Rugged::Config tests" do
4
4
  setup do
5
- @repo = Rugged::Repository.new(test_repo('testrepo.git'))
5
+ @repo = Rugged::Repository.new(temp_repo('testrepo.git'))
6
6
  end
7
7
 
8
8
  test "can read the config file from repo" do
@@ -1,4 +1,4 @@
1
- require File.expand_path "../test_helper", __FILE__
1
+ require "test_helper"
2
2
  require 'base64'
3
3
  require 'tempfile'
4
4
  require 'fileutils'
@@ -75,7 +75,7 @@ context "Rugged::Index reading stuff" do
75
75
  end
76
76
 
77
77
  test "can update entries" do
78
- now = Time.now
78
+ now = Time.at Time.now.to_i
79
79
  e = @index.get_entry(0)
80
80
 
81
81
  e[:oid] = "12ea3153a78002a988bb92f4123e7e831fd1138a"
@@ -1,4 +1,4 @@
1
- require File.expand_path "../test_helper", __FILE__
1
+ require "test_helper"
2
2
  require 'base64'
3
3
 
4
4
  context "Rugged::Lib stuff" do
@@ -1,4 +1,4 @@
1
- require File.expand_path "../test_helper", __FILE__
1
+ require "test_helper"
2
2
  require 'base64'
3
3
 
4
4
  context "Rugged::Object stuff" do
@@ -30,4 +30,17 @@ context "Rugged::Object stuff" do
30
30
  assert obj.read_raw
31
31
  end
32
32
 
33
+ test "can lookup an object by revision string" do
34
+ obj = @repo.rev_parse("v1.0")
35
+ assert "0c37a5391bbff43c37f0d0371823a5509eed5b1d", obj.oid
36
+ obj = @repo.rev_parse("v1.0^1")
37
+ assert "8496071c1b46c854b31185ea97743be6a8774479", obj.oid
38
+ end
39
+
40
+ test "can lookup just an object's oid by revision string" do
41
+ oid = @repo.rev_parse_oid("v1.0")
42
+ assert "0c37a5391bbff43c37f0d0371823a5509eed5b1d", oid
43
+ obj = @repo.rev_parse_oid("v1.0^1")
44
+ assert "8496071c1b46c854b31185ea97743be6a8774479", oid
45
+ end
33
46
  end
@@ -1,4 +1,4 @@
1
- require File.expand_path "../test_helper", __FILE__
1
+ require "test_helper"
2
2
 
3
3
  context "Rugged::Reference stuff" do
4
4
  setup do
@@ -1,4 +1,4 @@
1
- require File.expand_path "../test_helper", __FILE__
1
+ require "test_helper"
2
2
 
3
3
  context "Rugged::Tag tests" do
4
4
  setup do
@@ -1,4 +1,4 @@
1
- require File.expand_path "../test_helper", __FILE__
1
+ require "test_helper"
2
2
  require 'base64'
3
3
 
4
4
  context "Rugged::Repository packed stuff" do
@@ -1,4 +1,4 @@
1
- require File.expand_path "../test_helper", __FILE__
1
+ require 'test_helper'
2
2
  require 'base64'
3
3
 
4
4
  context "Rugged::Repository stuff" do
@@ -1,4 +1,4 @@
1
- require File.expand_path "../test_helper", __FILE__
1
+ require "test_helper"
2
2
 
3
3
  context "Rugged::Tag tests" do
4
4
  setup do
@@ -1,75 +1,61 @@
1
- dir = File.dirname(File.expand_path(__FILE__))
2
- $LOAD_PATH.unshift dir + '/../lib'
3
- $TEST_DIR = File.dirname(File.expand_path(__FILE__))
4
- $TESTING = true
5
- require 'test/unit'
6
1
  require 'tempfile'
2
+ require 'tmpdir'
7
3
  require 'rubygems'
4
+ require 'minitest/autorun'
8
5
  require 'rugged'
9
6
  require 'pp'
10
7
 
11
- ##
12
- # test/spec/mini 3
13
- # http://gist.github.com/25455
14
- # chris@ozmm.org
15
- #
16
- def context(*args, &block)
17
- return super unless (name = args.first) && block
18
- require 'test/unit'
19
- klass = Class.new(defined?(ActiveSupport::TestCase) ? ActiveSupport::TestCase : Test::Unit::TestCase) do
20
- def self.test(name, &block)
21
- define_method("test_#{name.gsub(/\W/,'_')}", &block) if block
22
- end
23
- def self.xtest(*args) end
24
- def self.setup(&block) define_method(:setup, &block) end
25
- def self.teardown(&block) define_method(:teardown, &block) end
26
- end
27
- (class << klass; self end).send(:define_method, :name) { name.gsub(/\W/,'_') }
28
- klass.class_eval &block
29
- ($contexts ||= []) << klass # make sure klass doesn't get GC'd
30
- klass
31
- end
8
+ # backwards compat with test/spec/mini 3
9
+ alias :context :describe
32
10
 
33
- def testpath(path)
34
- File.join($TEST_DIR, path)
35
- end
11
+ module Rugged
12
+ class TestCase < MiniTest::Spec
13
+ TEST_DIR = File.dirname(File.expand_path(__FILE__))
36
14
 
37
- def test_repo(repo)
38
- dir = temp_dir
39
- repo_dir = testpath(File.join('fixtures', repo, '.'))
40
- `git clone #{repo_dir} #{dir}`
41
- dir
42
- end
15
+ class << self
16
+ # backwards compat with test/spec/mini 3
17
+ alias :setup :before
18
+ alias :teardown :after
19
+ alias :test :it
20
+ end
43
21
 
44
- def temp_dir
45
- file = Tempfile.new('dir')
46
- dir = file.path
47
- file.unlink
48
- Dir.mkdir(dir)
49
- dir
50
- end
22
+ # backwards compat with test/unit
23
+ alias :assert_not_nil :refute_nil
24
+ alias :assert_raise :assert_raises
51
25
 
52
- def rm_loose(oid)
26
+ private
53
27
 
54
- base_path = File.join(@path, "objects", oid[0, 2])
28
+ def temp_repo(repo)
29
+ dir = Dir.mktmpdir 'dir'
30
+ repo_dir = File.join(TEST_DIR, (File.join('fixtures', repo, '.')))
31
+ `git clone #{repo_dir} #{dir}`
32
+ dir
33
+ end
55
34
 
56
- file = File.join(base_path, oid[2, 38])
57
- dir_contents = File.join(base_path, "*")
35
+ def rm_loose(oid)
36
+ base_path = File.join(@path, "objects", oid[0, 2])
58
37
 
59
- File.delete(file)
38
+ file = File.join(base_path, oid[2, 38])
39
+ dir_contents = File.join(base_path, "*")
60
40
 
61
- if Dir[dir_contents].empty?
62
- Dir.delete(base_path)
63
- end
64
- end
41
+ File.delete(file)
42
+
43
+ if Dir[dir_contents].empty?
44
+ Dir.delete(base_path)
45
+ end
46
+ end
65
47
 
66
- def with_default_encoding(encoding, &block)
67
- old_encoding = Encoding.default_internal
48
+ def with_default_encoding(encoding, &block)
49
+ old_encoding = Encoding.default_internal
68
50
 
69
- new_encoding = Encoding.find(encoding)
70
- Encoding.default_internal = new_encoding
51
+ new_encoding = Encoding.find(encoding)
52
+ Encoding.default_internal = new_encoding
71
53
 
72
- yield new_encoding
54
+ yield new_encoding
73
55
 
74
- Encoding.default_internal = old_encoding
56
+ Encoding.default_internal = old_encoding
57
+ end
58
+ end
75
59
  end
60
+
61
+ MiniTest::Spec.register_spec_type(/./, Rugged::TestCase)
@@ -1,4 +1,4 @@
1
- require File.expand_path "../test_helper", __FILE__
1
+ require "test_helper"
2
2
 
3
3
  context "Rugged::Tree tests" do
4
4
  setup do
@@ -1,4 +1,4 @@
1
- require File.expand_path "../test_helper", __FILE__
1
+ require "test_helper"
2
2
  require 'base64'
3
3
 
4
4
  context "Rugged::Walker stuff" do
metadata CHANGED
@@ -1,31 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rugged
3
3
  version: !ruby/object:Gem::Version
4
- hash: -2606657106
4
+ hash: 355
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 0
8
8
  - 17
9
9
  - 0
10
10
  - b
11
- - 1
12
- version: 0.17.0b1
11
+ - 2
12
+ version: 0.17.0b2
13
13
  platform: ruby
14
14
  authors:
15
- - GitHub, Inc
15
+ - Scott Chacon
16
+ - Vicent Marti
16
17
  autorequire:
17
18
  bindir: bin
18
19
  cert_chain: []
19
20
 
20
- date: 2012-06-11 00:00:00 +02:00
21
- default_executable:
21
+ date: 2012-06-15 00:00:00 Z
22
22
  dependencies: []
23
23
 
24
24
  description: |
25
25
  Rugged is a Ruby bindings to the libgit2 linkable C Git library. This is
26
26
  for testing and using the libgit2 library in a language that is awesome.
27
27
 
28
- email: libgit2@librelist.org
28
+ email: schacon@gmail.com
29
29
  executables: []
30
30
 
31
31
  extensions:
@@ -454,7 +454,6 @@ files:
454
454
  - ext/rugged/vendor/libgit2-dist/tests-clar/status/status_helpers.h
455
455
  - ext/rugged/vendor/libgit2-dist.tar.gz
456
456
  - ext/rugged/extconf.rb
457
- has_rdoc: true
458
457
  homepage: http://github.com/libgit2/rugged
459
458
  licenses: []
460
459
 
@@ -486,7 +485,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
486
485
  requirements: []
487
486
 
488
487
  rubyforge_project:
489
- rubygems_version: 1.6.2
488
+ rubygems_version: 1.8.17
490
489
  signing_key:
491
490
  specification_version: 3
492
491
  summary: Rugged is a Ruby binding to the libgit2 linkable library