Skip to content

Commit

Permalink
Merge branch 'jacquesg/owners'
Browse files Browse the repository at this point in the history
  • Loading branch information
jacquesg committed Aug 5, 2014
2 parents 4d0a8a0 + cba86bf commit 80f1156
Show file tree
Hide file tree
Showing 18 changed files with 149 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lib/Git/Raw/Blob.pm
Expand Up @@ -27,6 +27,10 @@ Create a new blob from the given buffer.
Retrieve the blob corresponding to C<$id>. This function is pretty much the
same as C<$repo-E<gt>lookup($id)> except that it only returns blobs.
=head2 owner( )
Retrieve the L<Git::Raw::Repository> owning the blob.
=head2 content( )
Retrieve the raw content of a blob.
Expand Down
4 changes: 4 additions & 0 deletions lib/Git/Raw/Commit.pm
Expand Up @@ -62,6 +62,10 @@ provided, "HEAD" is updated.
Retrieve the commit corresponding to C<$id>. This function is pretty much the
same as C<$repo-E<gt>lookup($id)> except that it only returns commits.
=head2 owner( )
Retrieve the L<Git::Raw::Repository> owning the commit.
=head2 id( )
Retrieve the id of the commit, as string.
Expand Down
4 changes: 4 additions & 0 deletions lib/Git/Raw/Index.pm
Expand Up @@ -18,6 +18,10 @@ B<WARNING>: The API of this module is unstable and may change without warning
=head1 METHODS
=head2 owner( )
Retrieve the L<Git::Raw::Repository> owning the index.
=head2 add( $entry )
Add C<$entry> to the index. C<$entry> should either be the path of a file
Expand Down
4 changes: 4 additions & 0 deletions lib/Git/Raw/Remote.pm
Expand Up @@ -64,6 +64,10 @@ Create a remote in memory (anonymous).
Load an existing remote.
=head2 owner( )
Retrieve the L<Git::Raw::Repository> owning the remote.
=head2 name( [ $name, \@problems ] )
Retrieve the name of the remote. If C<$name> is passed, the remote's name will
Expand Down
4 changes: 4 additions & 0 deletions lib/Git/Raw/Tag.pm
Expand Up @@ -48,6 +48,10 @@ L<Git::Raw::Signature> representing the tagger and a target object.
Retrieve the tag corresponding to C<$id>. This function is pretty much the same
as C<$repo-E<gt>lookup($id)> except that it only returns tags.
=head2 owner( )
Retrieve the L<Git::Raw::Repository> owning the tag.
=head2 foreach( $repo, $callback )
Run C<$callback> for every tag in the repo. The callback receives a tag object.
Expand Down
4 changes: 4 additions & 0 deletions lib/Git/Raw/Tree.pm
Expand Up @@ -23,6 +23,10 @@ B<WARNING>: The API of this module is unstable and may change without warning
Retrieve the tree corresponding to C<$id>. This function is pretty much the same
as C<$repo-E<gt>lookup($id)> except that it only returns trees.
=head2 owner( )
Retrieve the L<Git::Raw::Repository> owning the tree.
=head2 id( )
Retrieve the id of the tree, as string.
Expand Down
3 changes: 3 additions & 0 deletions t/01-repo.t
Expand Up @@ -46,6 +46,9 @@ is_deeply $repo -> status({'flags' => {'include_untracked' => 1, 'include_ignore
'subdir/' => {'flags' => ['ignored']}};

my $index = $repo -> index;
my $repo2 = $index -> owner;
isa_ok $repo2, 'Git::Raw::Repository';
is $repo2 -> path, $repo -> path;

ok (eval { $index -> capabilities });

Expand Down
4 changes: 4 additions & 0 deletions t/02-commit.t
Expand Up @@ -100,6 +100,10 @@ is $commit -> committer -> offset, $off;
is $commit -> time, $time;
is $commit -> offset, $off;

my $repo2 = $commit -> owner;
isa_ok $repo2, 'Git::Raw::Repository';
is $repo2 -> path, $repo -> path;

write_file($file, 'this is a test....');
is_deeply $repo -> status({}) -> {'test'}, {'flags' => ['worktree_modified'] };
ok (!eval { $repo -> reset($commit, {'type' => 'invalid_type'}) });
Expand Down
4 changes: 4 additions & 0 deletions t/03-tag.t
Expand Up @@ -28,6 +28,10 @@ my $tag = $repo -> tag($tag_name, $tag_msg, $me, $commit);
is $tag -> name, $tag_name;
is $tag -> message, $tag_msg;

my $repo2 = $tag -> owner;
isa_ok $repo2, 'Git::Raw::Repository';
is $repo2 -> path, $repo -> path;

is length ($tag -> id), 40;
my $lookup_tag = Git::Raw::Tag -> lookup($repo, $tag -> id);
isa_ok $lookup_tag, 'Git::Raw::Tag';
Expand Down
9 changes: 9 additions & 0 deletions t/05-tree.t
Expand Up @@ -22,6 +22,10 @@ $tree = $head -> tree;
ok $tree -> is_tree;
ok !$tree -> is_blob;

my $repo2 = $tree -> owner;
isa_ok $repo2, 'Git::Raw::Repository';
is $repo2 -> path, $repo -> path;

my $lookup_tree = Git::Raw::Tree -> lookup($repo, $tree -> id);
isa_ok $lookup_tree, 'Git::Raw::Tree';
$lookup_tree = Git::Raw::Tree -> lookup($repo, substr($tree -> id, 0, 7));
Expand All @@ -47,6 +51,11 @@ is $obj0 -> is_blob, 1;
is $obj0 -> content, 'this is a test';
is $obj0 -> size, '14';

my $repo3 = $obj0 -> owner;
isa_ok $repo3, 'Git::Raw::Repository';
is $repo3 -> path, $repo -> path;
is $repo2 -> path, $repo2 -> path;

my $blob_obj0 = Git::Raw::Blob -> lookup($repo, $obj0 -> id);
isa_ok $blob_obj0, 'Git::Raw::Blob';
is $blob_obj0 -> is_blob, 1;
Expand Down
3 changes: 3 additions & 0 deletions t/07-remote.t
Expand Up @@ -27,6 +27,9 @@ my $name = 'github';
my $url = 'git://github.com/ghedo/a_git_repository.git';

my $github = Git::Raw::Remote -> create($repo, $name, $url);
my $repo2 = $github -> owner;
isa_ok $repo2, 'Git::Raw::Repository';
is $repo2 -> path, $repo -> path;

is $github -> name, $name;
is $github -> url, $url;
Expand Down
17 changes: 17 additions & 0 deletions xs/Blob.xs
Expand Up @@ -66,6 +66,23 @@ lookup(class, repo, id)

OUTPUT: RETVAL

SV *
owner(self)
SV *self

PREINIT:
SV *repo;

CODE:
repo = GIT_SV_TO_MAGIC(self);

if (!repo)
croak_assert("No owner attached");

RETVAL = newRV_inc(repo);

OUTPUT: RETVAL

SV *
content(self)
Blob self
Expand Down
17 changes: 17 additions & 0 deletions xs/Commit.xs
Expand Up @@ -101,6 +101,23 @@ lookup(class, repo, id)

OUTPUT: RETVAL

SV *
owner(self)
SV *self

PREINIT:
SV *repo;

CODE:
repo = GIT_SV_TO_MAGIC(self);

if (!repo)
croak_assert("No owner attached");

RETVAL = newRV_inc(repo);

OUTPUT: RETVAL

SV *
id(self)
Commit self
Expand Down
17 changes: 17 additions & 0 deletions xs/Index.xs
Expand Up @@ -174,6 +174,23 @@ path(self)

OUTPUT: RETVAL

SV *
owner(self)
SV *self

PREINIT:
SV *repo;

CODE:
repo = GIT_SV_TO_MAGIC(self);

if (!repo)
croak_assert("No owner attached");

RETVAL = newRV_inc(repo);

OUTPUT: RETVAL

void
checkout(self, ...)
SV *self
Expand Down
2 changes: 0 additions & 2 deletions xs/Reference.xs
Expand Up @@ -129,11 +129,9 @@ owner(self)
SV *self

PREINIT:
Reference ref;
SV *repo;

CODE:
ref = GIT_SV_TO_PTR(Reference, self);
repo = GIT_SV_TO_MAGIC(self);

if (!repo)
Expand Down
17 changes: 17 additions & 0 deletions xs/Remote.xs
Expand Up @@ -100,6 +100,23 @@ load(class, repo, name)

OUTPUT: RETVAL

SV *
owner(self)
SV *self

PREINIT:
SV *repo;

CODE:
repo = GIT_SV_TO_MAGIC(self);

if (!repo)
croak_assert("No owner attached");

RETVAL = newRV_inc(repo);

OUTPUT: RETVAL

SV *
name(self, ...)
Remote self
Expand Down
17 changes: 17 additions & 0 deletions xs/Tag.xs
Expand Up @@ -72,6 +72,23 @@ lookup(class, repo, id)

OUTPUT: RETVAL

SV *
owner(self)
SV *self

PREINIT:
SV *repo;

CODE:
repo = GIT_SV_TO_MAGIC(self);

if (!repo)
croak_assert("No owner attached");

RETVAL = newRV_inc(repo);

OUTPUT: RETVAL

void
foreach(class, repo, cb)
SV *class
Expand Down
17 changes: 17 additions & 0 deletions xs/Tree.xs
Expand Up @@ -36,6 +36,23 @@ lookup(class, repo, id)

OUTPUT: RETVAL

SV *
owner(self)
SV *self

PREINIT:
SV *repo;

CODE:
repo = GIT_SV_TO_MAGIC(self);

if (!repo)
croak_assert("No owner attached");

RETVAL = newRV_inc(repo);

OUTPUT: RETVAL

SV *
id(self)
Tree self
Expand Down

0 comments on commit 80f1156

Please sign in to comment.