Module: Rugged

Defined in:
lib/rugged/tree.rb,
lib/rugged/index.rb,
lib/rugged/walker.rb,
lib/rugged/objects.rb,
lib/rugged/version.rb,
lib/rugged/repository.rb,
ext/rugged/rugged.c

Defined Under Namespace

Classes: Blob, Commit, Config, Index, Object, OdbObject, Reference, Remote, Repository, Tag, Tree, Walker

Constant Summary collapse

Version =
VERSION = '0.16.0'
SORT_NONE =

Constants

INT2FIX(0)
SORT_TOPO =
INT2FIX(1)
SORT_DATE =
INT2FIX(2)
SORT_REVERSE =
INT2FIX(4)
OBJ_ANY =
INT2FIX(GIT_OBJ_ANY)
OBJ_BAD =
INT2FIX(GIT_OBJ_BAD)
OBJ_COMMIT =
INT2FIX(GIT_OBJ_COMMIT)
OBJ_TREE =
INT2FIX(GIT_OBJ_TREE)
OBJ_BLOB =
INT2FIX(GIT_OBJ_BLOB)
OBJ_TAG =
INT2FIX(GIT_OBJ_TAG)
REF_OID =
INT2FIX(GIT_REF_OID)
REF_SYMBOLIC =
INT2FIX(GIT_REF_SYMBOLIC)

Class Method Summary collapse

Class Method Details

.hex_to_raw(hex) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'ext/rugged/rugged.c', line 30

static VALUE rb_git_hex_to_raw(VALUE self, VALUE hex)
{
	git_oid oid;

	Check_Type(hex, T_STRING);
	rugged_exception_check(git_oid_fromstr(&oid, StringValueCStr(hex)));

	return rugged_str_ascii(oid.id, 20);
}

.minimize_oid(*args) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'ext/rugged/rugged.c', line 81

static VALUE rb_git_minimize_oid(int argc, VALUE *argv, VALUE self)
{
	git_oid_shorten *shrt;
	int length, minlen = 7;
	VALUE rb_enum, rb_minlen, rb_block;

	rb_scan_args(argc, argv, "11&", &rb_enum, &rb_minlen, &rb_block);

	if (!NIL_P(rb_minlen)) {
		Check_Type(rb_minlen, T_FIXNUM);
		minlen = FIX2INT(rb_minlen);
	}

	if (!rb_respond_to(rb_enum, rb_intern("each")))
		rb_raise(rb_eTypeError, "Expecting an Enumerable instance");

	shrt = git_oid_shorten_new(minlen);

	rb_iterate(rb_each, rb_enum, &minimize_cb, (VALUE)shrt);
	length = git_oid_shorten_add(shrt, NULL);
	rugged_exception_check(length);

	if (RTEST(rb_block)) {
		VALUE yield_data[2];

		yield_data[0] = rb_block;
		yield_data[1] = INT2FIX(length);

		rb_iterate(rb_each, rb_enum, &minimize_yield, (VALUE)yield_data);
		git_oid_shorten_free(shrt);
		return Qnil;
	}

	git_oid_shorten_free(shrt);
	return INT2FIX(length);
}

.raw_to_hex(raw) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
# File 'ext/rugged/rugged.c', line 40

static VALUE rb_git_raw_to_hex(VALUE self, VALUE raw)
{
	git_oid oid;
	char out[40];

	Check_Type(raw, T_STRING);
	git_oid_fromraw(&oid, StringValueCStr(raw));
	git_oid_fmt(out, &oid);

	return rugged_str_new(out, 40, NULL);
}

.string_to_type(string_type) ⇒ Object



61
62
63
64
65
# File 'ext/rugged/rugged.c', line 61

static VALUE rb_git_string_to_type(VALUE self, VALUE string_type)
{
	Check_Type(string_type, T_STRING);
	return INT2FIX(git_object_string2type(StringValueCStr(string_type)));
}

.type_to_string(type) ⇒ Object



52
53
54
55
56
57
58
59
# File 'ext/rugged/rugged.c', line 52

static VALUE rb_git_type_to_string(VALUE self, VALUE type)
{
	const char *str;

	Check_Type(type, T_FIXNUM);
	str = git_object_type2string(FIX2INT(type));
	return str ? rugged_str_new2(str, NULL) : Qfalse;
}