From b123c6c606758f8bc0c139a83ab46d20957872a3 Mon Sep 17 00:00:00 2001 From: ZephyrTFA Date: Thu, 11 Jul 2024 19:54:51 -0400 Subject: [PATCH 1/3] add format str --- dmsrc/git.dm | 7 ++++--- src/git.rs | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/dmsrc/git.dm b/dmsrc/git.dm index 8e50256e..d72ee5a7 100644 --- a/dmsrc/git.dm +++ b/dmsrc/git.dm @@ -2,7 +2,8 @@ #define rustg_git_revparse(rev) RUSTG_CALL(RUST_G, "rg_git_revparse")(rev) /** - * Returns the date of the given revision in the format YYYY-MM-DD. - * Returns null if the revision is invalid. + * Returns the date of the given revision using the provided format. + * Defaults to returning %F which is YYYY-MM-DD */ -#define rustg_git_commit_date(rev) RUSTG_CALL(RUST_G, "rg_git_commit_date")(rev) +/proc/rustg_git_commit_date(rev, format = "%F") + return RUSTG_CALL("rg_git_commit_date")(rev, format) diff --git a/src/git.rs b/src/git.rs index e84d50c9..3d1f2d86 100644 --- a/src/git.rs +++ b/src/git.rs @@ -13,7 +13,7 @@ byond_fn!(fn rg_git_revparse(rev) { }) }); -byond_fn!(fn rg_git_commit_date(rev) { +byond_fn!(fn rg_git_commit_date(rev, format) { REPOSITORY.with(|repo| -> Option { let repo = repo.as_ref().ok()?; let rev = repo.rev_parse_single(rev).ok()?; @@ -21,6 +21,6 @@ byond_fn!(fn rg_git_commit_date(rev) { let commit = object.try_into_commit().ok()?; let commit_time = commit.committer().ok()?.time; let datetime = Utc.timestamp_opt(commit_time.seconds, 0).latest()?; - Some(datetime.format("%F").to_string()) + Some(datetime.format(format).to_string()) }) }); From a32e3eb267900d9c7ff19a3b6030b590a3a54114 Mon Sep 17 00:00:00 2001 From: ZeWaka Date: Thu, 11 Jul 2024 17:00:42 -0700 Subject: [PATCH 2/3] Update dmsrc/git.dm --- dmsrc/git.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dmsrc/git.dm b/dmsrc/git.dm index d72ee5a7..f12742eb 100644 --- a/dmsrc/git.dm +++ b/dmsrc/git.dm @@ -3,7 +3,7 @@ /** * Returns the date of the given revision using the provided format. - * Defaults to returning %F which is YYYY-MM-DD + * Defaults to returning %F which is YYYY-MM-DD. */ /proc/rustg_git_commit_date(rev, format = "%F") return RUSTG_CALL("rg_git_commit_date")(rev, format) From e9b78cac87a87090f705ba5fb365a1727e3d16f8 Mon Sep 17 00:00:00 2001 From: ZephyrTFA Date: Thu, 11 Jul 2024 20:51:10 -0400 Subject: [PATCH 3/3] forgot library name --- dmsrc/git.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dmsrc/git.dm b/dmsrc/git.dm index d72ee5a7..48334a45 100644 --- a/dmsrc/git.dm +++ b/dmsrc/git.dm @@ -6,4 +6,4 @@ * Defaults to returning %F which is YYYY-MM-DD */ /proc/rustg_git_commit_date(rev, format = "%F") - return RUSTG_CALL("rg_git_commit_date")(rev, format) + return RUSTG_CALL(RUST_G, "rg_git_commit_date")(rev, format)