Class: Rugged::Repository
- Inherits:
-
Object
- Object
- Rugged::Repository
- Defined in:
- lib/rugged/repository.rb,
ext/rugged/rugged_repo.c
Class Method Summary collapse
- .discover(*args) ⇒ Object
- .hash(rb_buffer, rb_type) ⇒ Object
- .hash_file(rb_path, rb_type) ⇒ Object
- .init_at(path, rb_is_bare) ⇒ Object
- .new(rb_path) ⇒ Object
Instance Method Summary collapse
- #bare? ⇒ Boolean
- #config ⇒ Object
- #config= ⇒ Object
- #empty? ⇒ Boolean
- #exists(hex) ⇒ Object
- #head ⇒ Object
- #head_detached? ⇒ Boolean
- #head_orphan? ⇒ Boolean
- #index ⇒ Object
- #index= ⇒ Object
- #lookup(oid) ⇒ Object
-
#path ⇒ Object
git_repository_head_orphan.
- #read(hex) ⇒ Object
- #refs ⇒ Object
- #status(*args) ⇒ Object
- #tags(pattern = "") ⇒ Object
- #walk(from, sorting = Rugged::SORT_DATE, &block) ⇒ Object
- #workdir ⇒ Object
- #workdir=(rb_workdir) ⇒ Object
- #write(rb_buffer, rub_type) ⇒ Object
Class Method Details
.discover(*args) ⇒ Object
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 |
# File 'ext/rugged/rugged_repo.c', line 352
static VALUE rb_git_repo_discover(int argc, VALUE *argv, VALUE self)
{
VALUE rb_path, rb_across_fs;
char repository_path[GIT_PATH_MAX];
int error, across_fs = 0;
rb_scan_args(argc, argv, "02", &rb_path, &rb_across_fs);
if (NIL_P(rb_path)) {
VALUE rb_dir = rb_const_get(rb_cObject, rb_intern("Dir"));
rb_path = rb_funcall(rb_dir, rb_intern("pwd"), 0);
}
if (!NIL_P(rb_across_fs)) {
across_fs = rugged_parse_bool(rb_across_fs);
}
Check_Type(rb_path, T_STRING);
error = git_repository_discover(
repository_path, GIT_PATH_MAX,
StringValueCStr(rb_path),
across_fs,
NULL
);
rugged_exception_check(error);
return rugged_str_new2(repository_path, NULL);
}
|
.hash(rb_buffer, rb_type) ⇒ Object
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
# File 'ext/rugged/rugged_repo.c', line 239
static VALUE rb_git_repo_hash(VALUE self, VALUE rb_buffer, VALUE rb_type)
{
int error;
git_oid oid;
Check_Type(rb_buffer, T_STRING);
error = git_odb_hash(&oid,
RSTRING_PTR(rb_buffer),
RSTRING_LEN(rb_buffer),
rugged_get_otype(rb_type)
);
rugged_exception_check(error);
return rugged_create_oid(&oid);
}
|
.hash_file(rb_path, rb_type) ⇒ Object
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
# File 'ext/rugged/rugged_repo.c', line 256
static VALUE rb_git_repo_hashfile(VALUE self, VALUE rb_path, VALUE rb_type)
{
int error;
git_oid oid;
Check_Type(rb_path, T_STRING);
error = git_odb_hashfile(&oid,
StringValueCStr(rb_path),
rugged_get_otype(rb_type)
);
rugged_exception_check(error);
return rugged_create_oid(&oid);
}
|
.init_at(path, rb_is_bare) ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'ext/rugged/rugged_repo.c', line 144
static VALUE rb_git_repo_init_at(VALUE klass, VALUE path, VALUE rb_is_bare)
{
git_repository *repo;
int error, is_bare;
is_bare = rugged_parse_bool(rb_is_bare);
Check_Type(path, T_STRING);
error = git_repository_init(&repo, StringValueCStr(path), is_bare);
rugged_exception_check(error);
return rugged_repo_new(klass, repo);
}
|
.new(rb_path) ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'ext/rugged/rugged_repo.c', line 131
static VALUE rb_git_repo_new(VALUE klass, VALUE rb_path)
{
git_repository *repo;
int error = 0;
Check_Type(rb_path, T_STRING);
error = git_repository_open(&repo, StringValueCStr(rb_path));
rugged_exception_check(error);
return rugged_repo_new(klass, repo);
}
|
Instance Method Details
#bare? ⇒ Boolean
#config ⇒ Object
#config= ⇒ Object
#empty? ⇒ Boolean
#exists(hex) ⇒ Object
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'ext/rugged/rugged_repo.c', line 201
static VALUE rb_git_repo_exists(VALUE self, VALUE hex)
{
git_repository *repo;
git_odb *odb;
git_oid oid;
int error;
VALUE rb_result;
Data_Get_Struct(self, git_repository, repo);
Check_Type(hex, T_STRING);
error = git_repository_odb(&odb, repo);
rugged_exception_check(error);
error = git_oid_fromstr(&oid, StringValueCStr(hex));
rugged_exception_check(error);
rb_result = git_odb_exists(odb, &oid) ? Qtrue : Qfalse;
git_odb_free(odb);
return rb_result;
}
|
#head ⇒ Object
11 12 13 14 |
# File 'lib/rugged/repository.rb', line 11 def head ref = Reference.lookup(self, "HEAD") ref.resolve end |
#head_detached? ⇒ Boolean
#head_orphan? ⇒ Boolean
#index ⇒ Object
#index= ⇒ Object
#lookup(oid) ⇒ Object
16 17 18 |
# File 'lib/rugged/repository.rb', line 16 def lookup(oid) Rugged::Object.lookup(self, oid) end |
#path ⇒ Object
git_repository_head_orphan
320 321 322 323 324 325 |
# File 'ext/rugged/rugged_repo.c', line 320
static VALUE rb_git_repo_path(VALUE self)
{
git_repository *repo;
Data_Get_Struct(self, git_repository, repo);
return rugged_str_new2(git_repository_path(repo), NULL);
}
|
#read(hex) ⇒ Object
224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'ext/rugged/rugged_repo.c', line 224
static VALUE rb_git_repo_read(VALUE self, VALUE hex)
{
git_repository *repo;
git_oid oid;
int error;
Data_Get_Struct(self, git_repository, repo);
Check_Type(hex, T_STRING);
error = git_oid_fromstr(&oid, StringValueCStr(hex));
rugged_exception_check(error);
return rugged_raw_read(repo, &oid);
}
|
#refs ⇒ Object
20 21 22 |
# File 'lib/rugged/repository.rb', line 20 def refs Rugged::Reference.each(self) end |
#status(*args) ⇒ Object
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 |
# File 'ext/rugged/rugged_repo.c', line 417
static VALUE rb_git_repo_status(int argc, VALUE *argv, VALUE self)
{
int error;
VALUE rb_path;
git_repository *repo;
Data_Get_Struct(self, git_repository, repo);
if (rb_scan_args(argc, argv, "01", &rb_path) == 1) {
unsigned int flags;
Check_Type(rb_path, T_STRING);
error = git_status_file(&flags, repo, StringValueCStr(rb_path));
rugged_exception_check(error);
return flags_to_rb(flags);
}
if (!rb_block_given_p())
rb_raise(rb_eRuntimeError,
"A block was expected for iterating through "
"the repository contents.");
error = git_status_foreach(
repo,
&rugged__status_cb,
(void *)rb_block_proc()
);
rugged_exception_check(error);
return Qnil;
}
|
#tags(pattern = "") ⇒ Object
24 25 26 |
# File 'lib/rugged/repository.rb', line 24 def (pattern="") Rugged::Tag.each(self, pattern) end |
#walk(from, sorting = Rugged::SORT_DATE, &block) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/rugged/repository.rb', line 4 def walk(from, sorting=Rugged::SORT_DATE, &block) walker = Rugged::Walker.new(self) walker.sorting(sorting) walker.push(from) walker.each(&block) end |
#workdir ⇒ Object
327 328 329 330 331 332 333 334 335 336 |
# File 'ext/rugged/rugged_repo.c', line 327
static VALUE rb_git_repo_workdir(VALUE self)
{
git_repository *repo;
const char *workdir;
Data_Get_Struct(self, git_repository, repo);
workdir = git_repository_workdir(repo);
return workdir ? rugged_str_new2(workdir, NULL) : Qnil;
}
|
#workdir=(rb_workdir) ⇒ Object
338 339 340 341 342 343 344 345 346 347 348 349 350 |
# File 'ext/rugged/rugged_repo.c', line 338
static VALUE rb_git_repo_set_workdir(VALUE self, VALUE rb_workdir)
{
git_repository *repo;
Data_Get_Struct(self, git_repository, repo);
Check_Type(rb_workdir, T_STRING);
rugged_exception_check(
git_repository_set_workdir(repo, StringValueCStr(rb_workdir))
);
return Qnil;
}
|
#write(rb_buffer, rub_type) ⇒ Object
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
# File 'ext/rugged/rugged_repo.c', line 272
static VALUE rb_git_repo_write(VALUE self, VALUE rb_buffer, VALUE rub_type)
{
git_repository *repo;
git_odb_stream *stream;
git_odb *odb;
git_oid oid;
int error;
git_otype type;
Data_Get_Struct(self, git_repository, repo);
error = git_repository_odb(&odb, repo);
rugged_exception_check(error);
type = rugged_get_otype(rub_type);
error = git_odb_open_wstream(&stream, odb, RSTRING_LEN(rb_buffer), type);
rugged_exception_check(error);
git_odb_free(odb);
error = stream->write(stream, RSTRING_PTR(rb_buffer), RSTRING_LEN(rb_buffer));
rugged_exception_check(error);
error = stream->finalize_write(&oid, stream);
rugged_exception_check(error);
return rugged_create_oid(&oid);
}
|