emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/hcel c996eaabb6 4/5: Adding version check


From: ELPA Syncer
Subject: [elpa] externals/hcel c996eaabb6 4/5: Adding version check
Date: Tue, 4 Oct 2022 21:57:41 -0400 (EDT)

branch: externals/hcel
commit c996eaabb66e2ca4b1b9e16c65dc1d063f96383a
Author: Yuchen Pei <hi@ypei.me>
Commit: Yuchen Pei <hi@ypei.me>

    Adding version check
---
 hcel-client.el | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/hcel-client.el b/hcel-client.el
index fef8bf697c..d88a6a1472 100644
--- a/hcel-client.el
+++ b/hcel-client.el
@@ -27,6 +27,29 @@
   :group 'hcel :type '(string))
 
 (defvar hcel-client-buffer-name "*hcel-client*")
+(defvar hcel-server-version "0.1.0.0"
+  "The version of hcel the server we are talking to.")
+
+(defun hcel-fetch-server-version ()
+  (interactive)
+  (setq hcel-server-version
+        (condition-case nil
+            (hcel-url-fetch-json
+             (concat hcel-host "/api/greet"))
+          (error "0.1.0.0"))))
+
+(hcel-fetch-server-version)
+
+(defun hcel-require-server-version (lower-bound higher-bound)
+  (unless (and (or (not lower-bound)
+                   (string< lower-bound hcel-server-version)
+                   (equal lower-bound hcel-server-version))
+               (or (not higher-bound)
+                   (string> higher-bound hcel-server-version)
+                   (equal higher-bound hcel-server-version)))
+    (error
+     "Server version cannot be satisfied.  Actual version: %s.  Required 
version: lower bound - %s, higher bound - %s"
+     hcel-server-version lower-bound higher-bound)))
 
 (defun hcel-api-packages ()
   (let ((packages
@@ -161,6 +184,7 @@ Example of approximate location:
 
 (defun hcel-api-global-identifier-a (package-id component-id module-name entity
                                             name)
+  (hcel-require-server-version "1.0.0" nil)
   (hcel-url-fetch-json
    (concat hcel-host "/api/globalIdentifierA/"
            (hcel-format-package-id package-id "-") "/" component-id "/"
@@ -168,6 +192,7 @@ Example of approximate location:
 
 (defun hcel-api-global-identifier-e (package-id module-path start-line 
start-column
                                                 end-line end-column name)
+  (hcel-require-server-version "1.0.0" nil)
   (hcel-url-fetch-json
    (concat hcel-host "/api/globalIdentifierE/"
            (hcel-format-package-id package-id "-") "/"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]