Class: Rugged::Walker

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/rugged/walker.rb,
ext/rugged/rugged_revwalk.c

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(rb_repo) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'ext/rugged/rugged_revwalk.c', line 42

static VALUE rb_git_walker_new(VALUE klass, VALUE rb_repo)
{
	git_repository *repo;
	git_revwalk *walk;
	int error;

	Data_Get_Struct(rb_repo, git_repository, repo);

	error = git_revwalk_new(&walk, repo);
	rugged_exception_check(error);

	return rugged_walker_new(klass, rb_repo, walk);;
}

Instance Method Details

#eachObject



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'ext/rugged/rugged_revwalk.c', line 56

static VALUE rb_git_walker_each(VALUE self)
{
	git_revwalk *walk;
	git_commit *commit;
	git_repository *repo;
	git_oid commit_oid;
	int error;

	Data_Get_Struct(self, git_revwalk, walk);
	repo = git_revwalk_repository(walk);

	if (!rb_block_given_p())
		return rb_funcall(self, rb_intern("to_enum"), 0);

	while ((error = git_revwalk_next(&commit_oid, walk)) == 0) {
		error = git_commit_lookup(&commit, repo, &commit_oid);
		rugged_exception_check(error);

		rb_yield(rugged_object_new(rugged_owner(self), (git_object *)commit));
	}

	if (error != GIT_EREVWALKOVER)
		rugged_exception_check(error);

	return Qnil;
}

#hide(rb_commit) ⇒ Object



97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'ext/rugged/rugged_revwalk.c', line 97

static VALUE rb_git_walker_hide(VALUE self, VALUE rb_commit)
{
	git_revwalk *walk;
	git_commit *commit;

	Data_Get_Struct(self, git_revwalk, walk);

	commit = (git_commit *)rugged_object_load(
		git_revwalk_repository(walk), rb_commit, GIT_OBJ_COMMIT);

	git_revwalk_hide(walk, git_object_id((git_object *)commit));
	return Qnil;
}

#push(rb_commit) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'ext/rugged/rugged_revwalk.c', line 83

static VALUE rb_git_walker_push(VALUE self, VALUE rb_commit)
{
	git_revwalk *walk;
	git_commit *commit;

	Data_Get_Struct(self, git_revwalk, walk);

	commit = (git_commit *)rugged_object_load(
		git_revwalk_repository(walk), rb_commit, GIT_OBJ_COMMIT);

	git_revwalk_push(walk, git_object_id((git_object *)commit));
	return Qnil;
}

#resetObject



119
120
121
122
123
124
125
# File 'ext/rugged/rugged_revwalk.c', line 119

static VALUE rb_git_walker_reset(VALUE self)
{
	git_revwalk *walk;
	Data_Get_Struct(self, git_revwalk, walk);
	git_revwalk_reset(walk);
	return Qnil;
}

#sorting(ruby_sort_mode) ⇒ Object



111
112
113
114
115
116
117
# File 'ext/rugged/rugged_revwalk.c', line 111

static VALUE rb_git_walker_sorting(VALUE self, VALUE ruby_sort_mode)
{
	git_revwalk *walk;
	Data_Get_Struct(self, git_revwalk, walk);
	git_revwalk_sorting(walk, FIX2INT(ruby_sort_mode));
	return Qnil;
}

#walkObject



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'ext/rugged/rugged_revwalk.c', line 56

static VALUE rb_git_walker_each(VALUE self)
{
	git_revwalk *walk;
	git_commit *commit;
	git_repository *repo;
	git_oid commit_oid;
	int error;

	Data_Get_Struct(self, git_revwalk, walk);
	repo = git_revwalk_repository(walk);

	if (!rb_block_given_p())
		return rb_funcall(self, rb_intern("to_enum"), 0);

	while ((error = git_revwalk_next(&commit_oid, walk)) == 0) {
		error = git_commit_lookup(&commit, repo, &commit_oid);
		rugged_exception_check(error);

		rb_yield(rugged_object_new(rugged_owner(self), (git_object *)commit));
	}

	if (error != GIT_EREVWALKOVER)
		rugged_exception_check(error);

	return Qnil;
}