branch: externals/vc-jj
commit bf62502af0cd623bdb401173419dff8bfed21d8e
Author: Rudi Schlatte <[email protected]>
Commit: Rudi Schlatte <[email protected]>

    Implement reading jj's version
    
    This can be used for feature tests so we can support older jj
    versions.
    
    Will be helpful for #162, #61, possibly others.
---
 vc-jj-tests.el | 6 ++++++
 vc-jj.el       | 7 +++++++
 2 files changed, 13 insertions(+)

diff --git a/vc-jj-tests.el b/vc-jj-tests.el
index 389635b415..86d6b979aa 100644
--- a/vc-jj-tests.el
+++ b/vc-jj-tests.el
@@ -109,6 +109,12 @@ timestamps and random number seed (and thereby change ids) 
is needed."
              (,name (file-truename (vc-jj-root ,name))))
          ,@body))))
 
+;;;; Check if jujutsu's version number is parseable
+
+(ert-deftest vc-jj-test-jj-version ()
+  "Test that we can parse jj's version info."
+  (version< "0.0.1" (vc-jj--program-version)))
+
 ;;;; State-querying tests
 
 (defun vc-jj-test--dir-status-files-update-function 
(files-and-states-and-extra _partial-results-p)
diff --git a/vc-jj.el b/vc-jj.el
index 66ffabb34e..199d983a23 100644
--- a/vc-jj.el
+++ b/vc-jj.el
@@ -380,6 +380,13 @@ included in ARGS."
     (apply #'vc-do-command (or buffer "*vc*") okstatus vc-jj-program nil
            (append global-switches args filesets))))
 
+(defun vc-jj--program-version ()
+  "Return the version of the installed jj executable.
+The return value is usable as input to `version<' and related functions."
+  (when-let* ((raw-version (car (vc-jj--process-lines nil "--version")))
+              (version (string-trim raw-version "jj " nil)))
+    version))
+
 ;;; BACKEND PROPERTIES
 
 ;;;; revision-granularity

Reply via email to