Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add Tag API

create lightweight tags, delete them
  • Loading branch information...
commit f7ca9ac06d2c4689a2732e209fb8ab1c6ab68299 1 parent 48763dd
@sa1 sa1 authored
View
4 setup.winxed
@@ -50,6 +50,7 @@ function setup_stable_libraries(var parrot_libgit2) {
'Common',
'Commit',
'Index',
+ 'Object',
'Odb',
'Oid',
'RefCache',
@@ -57,7 +58,8 @@ function setup_stable_libraries(var parrot_libgit2) {
'Repository',
'Remote',
'RevParse',
- 'RevWalk'
+ 'RevWalk',
+ 'Tag'
];
var core = [
View
20 src/Git2/Object.winxed
@@ -0,0 +1,20 @@
+$include_const 'datatypes.pasm';
+$include_const "iglobals.pasm";
+
+namespace Git2{
+ class Common;
+}
+
+namespace Git2{
+ class Object {
+ var ptr;
+ function Object(repo, oid){
+ using Git2.Git.object_lookup;
+ self.ptr = object_lookup(repo.ptr, oid.ptr);
+ }
+ function free(){
+ using Git2.Raw.git_object_free;
+ git_object_free(self.ptr);
+ }
+ }
+}
View
1  src/Git2/Oid.winxed
@@ -25,6 +25,7 @@ namespace Git2 {
using Git2.Raw.git_oid_fromstr;
using cstring;
int rc = git_oid_fromstr(self.ptr, cstring(hex));
+ return rc;
}
}
}
View
39 src/Git2/Tag.winxed
@@ -0,0 +1,39 @@
+$include_const 'datatypes.pasm';
+$include_const "iglobals.pasm";
+
+namespace Git2{
+ class Common;
+}
+
+namespace Git2{
+ class Tag {
+ var ptr;
+ function Tag(){
+ }
+ function create_lightweight(oid, repo, name, target){
+ using Git2.Raw.git_tag_create_lightweight;
+ using cstring;
+ int ret = git_tag_create_lightweight(oid.ptr, repo.ptr, cstring(name), target.ptr, 0);
+ if (ret < 0){
+ print("Error creating tag.\n");
+ }
+ return ret;
+ }
+ function lookup(repo, oid){
+ using Git2.Git.tag_lookup;
+ self.ptr = tag_lookup(repo.ptr, oid.ptr);
+ }
+ function free(){
+ using Git2.Raw.git_tag_free;
+ git_tag_free(self.ptr);
+ }
+ function delete(repo, name){
+ using Git2.Raw.git_tag_delete;
+ int ret = git_tag_delete(repo.ptr, cstring(name));
+ if (ret < 0){
+ print("Error deleting tag");
+ }
+ return ret;
+ }
+ }
+}
View
20 src/parrotgit.c
@@ -137,3 +137,23 @@ git_object * revparse_single(git_repository * repo, char * spec){
}
return object;
}
+
+git_object * object_lookup(git_repository * repo, const git_oid * oid){
+ git_object * object;
+ int ret;
+ ret = git_object_lookup(&object, repo, oid, GIT_OBJ_ANY);
+ if (ret < 0){
+ fprintf(stderr, "Error looking up object.\n");
+ }
+ return object;
+}
+
+git_tag * tag_lookup(git_repository * repo, const git_oid * oid){
+ git_tag * tag;
+ int ret;
+ ret = git_tag_lookup(&tag, repo, oid);
+ if (ret < 0){
+ fprintf(stderr, "Error in tag lookup: % d\n", ret);
+ }
+ return tag;
+}
View
4 src/parrotgit.nci
@@ -19,4 +19,6 @@ p parent pi
p new_revwalk p
p blob_lookup pp
p remote_create ppp
-p revparse_single pp
+p revparse_single pp
+p object_lookup pp
+p tag_lookup pp
View
4 src/parrotgit.pir
@@ -29,4 +29,8 @@
set_global ['Git2';'Git'], 'remote_create', nci
dlfunc nci, lib, 'revparse_single', 'ppp'
set_global ['Git2';'Git'], 'revparse_single', nci
+ dlfunc nci, lib, 'object_lookup', 'ppp'
+ set_global ['Git2';'Git'], 'object_lookup', nci
+ dlfunc nci, lib, 'tag_lookup', 'ppp'
+ set_global ['Git2';'Git'], 'tag_lookup', nci
.end
View
29 t/winxed/001_load.t
@@ -16,6 +16,8 @@ $load "./src/Git2/AttrCache.pbc";
$load "./src/Git2/Blob.pbc";
$load "./src/Git2/Remote.pbc";
$load "./src/Git2/RevParse.pbc";
+$load "./src/Git2/Object.pbc";
+$load "./src/Git2/Tag.pbc";
$load "dumper.pbc";
$include_const 'datatypes.pasm';
@@ -33,6 +35,8 @@ namespace Git2 {
class RevWalk;
class Remote;
class Blob;
+ class Object;
+ class Tag;
}
class Test_git2_repository_open {
@@ -255,6 +259,31 @@ class Test_git2_repository_open {
int result;
${spawnw result, cmd};
}
+
+ function git_tag(){
+ using Git2.Oid;
+ using Git2.Tag;
+ using Git2.Repository;
+ using Git2.Object;
+
+ var repo = new Git2.Repository(".");
+
+ var hex = "e1380b1f60babf677921c4a9b5e92acda0b15e18";
+ var git_oid = new Git2.Oid();
+ int ret = git_oid.oid_from_str(hex);
+
+ var obj = new Git2.Object(repo, git_oid);
+
+ var target_oid = new Git2.Oid();
+ var name = "Test_Tag";
+
+ var tag = new Git2.Tag();
+ int rc1 = tag.create_lightweight(target_oid, repo, name, obj);
+ self.assert.equal(rc1, 0);
+
+ rc1 = tag.delete(repo, name);
+ self.assert.equal(rc1, 0);
+ }
}
function main[main]() {
using Rosella.Test.test;
Please sign in to comment.
Something went wrong with that request. Please try again.