summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeah (ctucx) <leah@ctu.cx>2021-03-18 00:21:22 +0100
committerLeah (ctucx) <leah@ctu.cx>2021-03-18 00:21:22 +0100
commitb618202dea40a066535144ec552259c83d3ea944 (patch)
treea76f3770f047db667cbbbe5ccb5d70a2bb291e39
parenta2b30f12bd5ae2a4a770b91fb489b4ccaff46c3e (diff)
downloadnimgit-b618202dea40a066535144ec552259c83d3ea944.tar.gz
nimgit-b618202dea40a066535144ec552259c83d3ea944.tar.bz2
nimgit-b618202dea40a066535144ec552259c83d3ea944.zip
commit.nim: new procs type, shortId
-rw-r--r--nimgit/commit.nim25
1 files changed, 9 insertions, 16 deletions
diff --git a/nimgit/commit.nim b/nimgit/commit.nim
index f0f7a05..0cac63b 100644
--- a/nimgit/commit.nim
+++ b/nimgit/commit.nim
@@ -1,6 +1,6 @@
import times
import nimgit2
-import types, free, utils, oid
+import types, free, utils, oid, objects
proc lookupCommit* (repo: GitRepository, oid: GitObjectId): GitCommit =
let error = git_commit_lookup(addr result, repo, oid)
@@ -9,6 +9,8 @@ proc lookupCommit* (repo: GitRepository, oid: GitObjectId): GitCommit =
free(result)
raise newException(CatchableError, "Commit lookup failed: " & $error.getResultCode)
+proc type* (obj: GitCommit): GitObjectKind = cast[GitObject](obj).type
+
proc owner* (commit: GitCommit): GitRepository = git_commit_owner(commit)
proc repo* (commit: GitCommit): GitRepository = commit.owner()
@@ -19,6 +21,8 @@ proc id* (commit: GitCommit): GitObjectId = git_commit_id(commit)
proc `$`* (commit: GitCommit): string = $commit.id()
+proc shortId* (commit: GitCommit): string = cast[GitObject](commit).shortId()
+
proc summary* (commit: GitCommit): string = $git_commit_summary(commit)
proc body* (commit: GitCommit): string = $git_commit_body(commit)
@@ -53,24 +57,13 @@ proc gpgSignature* (commit: GitCommit): (string, string) =
proc time* (commit: GitCommit): GitTime =
- result.time = fromUnix(git_commit_time(commit))
- result.offset = git_commit_time_offset(commit)
-
-
-proc author* (commit: GitCommit): GitSignature =
- let author = git_commit_author(commit)
-
- result.name = $author.name
- result.email = $author.email
- result.when = parseGitTime(author.when)
+ result.time = fromUnix(git_commit_time(commit))
+ result.offset = git_commit_time_offset(commit)
-proc committer* (commit: GitCommit): GitSignature =
- let author = git_commit_committer(commit)
- result.name = $author.name
- result.email = $author.email
- result.when = parseGitTime(author.when)
+proc author* (commit: GitCommit): GitSignature = git_commit_author(commit).parseGitSignature
+proc committer* (commit: GitCommit): GitSignature = git_commit_committer(commit).parseGitSignature
proc hasParents* (commit: GitCommit): bool = cast[bool](git_commit_parentcount(commit))