From: Felipe Contreras <felipe.contreras@gmail.com>
To: notmuch@notmuchmail.org
Subject: [PATCH 1/3] ruby: add database.revision
Date: Fri, 31 Mar 2023 14:53:36 -0600 [thread overview]
Message-ID: <20230331205338.174779-2-felipe.contreras@gmail.com> (raw)
In-Reply-To: <20230331205338.174779-1-felipe.contreras@gmail.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
bindings/ruby/database.c | 18 ++++++++++++++++++
bindings/ruby/defs.h | 3 +++
bindings/ruby/init.c | 1 +
3 files changed, 22 insertions(+)
diff --git a/bindings/ruby/database.c b/bindings/ruby/database.c
index b6de1254..4372afa1 100644
--- a/bindings/ruby/database.c
+++ b/bindings/ruby/database.c
@@ -479,3 +479,21 @@ notmuch_rb_database_query_create (int argc, VALUE *argv, VALUE self)
return Data_Wrap_Notmuch_Object (notmuch_rb_cQuery, ¬much_rb_query_type, query);
}
+
+/*
+ * call-seq: DB.revision => Array
+ *
+ * Returns the commutted database revision and UUID.
+ */
+VALUE
+notmuch_rb_database_revision (VALUE self)
+{
+ notmuch_database_t *db;
+ unsigned long rev;
+ const char *uuid;
+
+ Data_Get_Notmuch_Database (self, db);
+
+ rev = notmuch_database_get_revision (db, &uuid);
+ return rb_ary_new3(2, INT2FIX (rev), rb_str_new2 (uuid));
+}
diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h
index e2541e8f..c4943681 100644
--- a/bindings/ruby/defs.h
+++ b/bindings/ruby/defs.h
@@ -208,6 +208,9 @@ notmuch_rb_database_get_all_tags (VALUE self);
VALUE
notmuch_rb_database_query_create (int argc, VALUE *argv, VALUE self);
+VALUE
+notmuch_rb_database_revision (VALUE self);
+
/* directory.c */
VALUE
notmuch_rb_directory_destroy (VALUE self);
diff --git a/bindings/ruby/init.c b/bindings/ruby/init.c
index cd9f04cd..c78242a0 100644
--- a/bindings/ruby/init.c
+++ b/bindings/ruby/init.c
@@ -283,6 +283,7 @@ Init_notmuch (void)
notmuch_rb_database_find_message_by_filename, 1); /* in database.c */
rb_define_method (notmuch_rb_cDatabase, "all_tags", notmuch_rb_database_get_all_tags, 0); /* in database.c */
rb_define_method (notmuch_rb_cDatabase, "query", notmuch_rb_database_query_create, -1); /* in database.c */
+ rb_define_method (notmuch_rb_cDatabase, "revision", notmuch_rb_database_revision, 0); /* in database.c */
/*
* Document-class: Notmuch::Directory
--
2.40.0
next prev parent reply other threads:[~2023-03-31 20:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-31 20:53 [PATCH 0/3] ruby: api updates Felipe Contreras
2023-03-31 20:53 ` Felipe Contreras [this message]
2023-05-29 11:15 ` [PATCH 1/3] ruby: add database.revision David Bremner
2023-03-31 20:53 ` [PATCH 2/3] ruby: add directory.delete Felipe Contreras
2023-05-29 11:24 ` David Bremner
2023-03-31 20:53 ` [PATCH 3/3] ruby: add db.{set,get}_config Felipe Contreras
2023-05-29 11:32 ` David Bremner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230331205338.174779-2-felipe.contreras@gmail.com \
--to=felipe.contreras@gmail.com \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).