Skip to content

Commit

Permalink
Remove the pkg-info dep
Browse files Browse the repository at this point in the history
This will simplify the submission of CIDER to NonGNU ELPA.
  • Loading branch information
bbatsov committed Dec 28, 2021
1 parent 6a1288f commit 096c184
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 37 deletions.
11 changes: 3 additions & 8 deletions cider-util.el
Original file line number Diff line number Diff line change
Expand Up @@ -388,20 +388,15 @@ propertized (defaults to current buffer)."
(unless (equal "unspecified-bg" color)
(color-lighten-name color (if darkp 5 -5)))))

(autoload 'pkg-info-version-info "pkg-info.el")

(defvar cider-version)
(defvar cider-codename)

(defun cider--version ()
"Retrieve CIDER's version.
A codename is added to stable versions."
(let ((version (condition-case nil
(pkg-info-version-info 'cider)
(error cider-version))))
(if (string-match-p "-snapshot" cider-version)
version
(format "%s (%s)" version cider-codename))))
(if (string-match-p "-snapshot" cider-version)
cider-version
(format "%s (%s)" cider-version cider-codename)))


;;; Strings
Expand Down
10 changes: 5 additions & 5 deletions cider.el
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
;; Maintainer: Bozhidar Batsov <bozhidar@batsov.dev>
;; URL: http://www.github.com/clojure-emacs/cider
;; Version: 1.2.0
;; Package-Requires: ((emacs "26") (clojure-mode "5.12") (parseedn "1.0.6") (pkg-info "0.4") (queue "0.2") (spinner "1.7") (seq "2.22") (sesman "0.3.2"))
;; Package-Requires: ((emacs "26") (clojure-mode "5.12") (parseedn "1.0.6") (queue "0.2") (spinner "1.7") (seq "2.22") (sesman "0.3.2"))
;; Keywords: languages, clojure, cider

;; This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -92,10 +92,10 @@
(require 'seq)
(require 'sesman)

(defconst cider-version "1.2.0"
"Fallback version used when it cannot be extracted automatically.
Normally it won't be used, unless `pkg-info' fails to extract the
version from the CIDER package or library.")
(defconst cider-version
(eval-when-compile
(lm-version (or load-file-name buffer-file-name)))
"The current version of CIDER.")

(defconst cider-codename "Nice"
"Codename used to denote stable releases.")
Expand Down
16 changes: 0 additions & 16 deletions test/cider-repl-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,6 @@

(describe "when the cider package version information is available"
(it "returns the repl banner string"
(spy-on 'pkg-info-version-info :and-return-value "0.12.0")
(expect (cider-repl--clojure-banner) :to-equal
";; Connected to nREPL server - nrepl://localhost:54018
;; CIDER 0.12.0 (Seattle), nREPL 0.5.3
;; Clojure 1.8.0, Java 1.8.0_31
;; Docs: (doc function-name)
;; (find-doc part-of-name)
;; Source: (source function-name)
;; Javadoc: (javadoc java-object-or-class)
;; Exit: <C-c C-q>
;; Results: Stored in vars *1, *2, *3, an exception in *e;
")))

(describe "when the cider package version information is not available"
(it "returns the repl banner string"
(spy-on 'pkg-info-version-info :and-throw-error '(error "No package version"))
(expect (cider-repl--clojure-banner) :to-equal
";; Connected to nREPL server - nrepl://localhost:54018
;; CIDER 0.12.0 (Seattle), nREPL 0.5.3
Expand Down
8 changes: 0 additions & 8 deletions test/cider-util-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,12 @@ buffer."
(describe "cider--version"
:var (cider-version cider-codename)

(it "handles version unavailable error"
(spy-on 'pkg-info-version-info :and-throw-error '(error "No version"))
(setq cider-version "0.11.0"
cider-codename "Victory")
(expect (cider--version) :to-equal "0.11.0 (Victory)"))

(it "returns correct version number when available"
(spy-on 'pkg-info-version-info :and-return-value "0.11.0")
(setq cider-version "0.11.0"
cider-codename "Victory")
(expect (cider--version) :to-equal "0.11.0 (Victory)"))

(it "handles snapshot versions"
(spy-on 'pkg-info-version-info :and-return-value "0.11.0snapshot (package: 20160301.2217)")
(setq cider-version "0.11.0-snapshot"
cider-codename "Victory")
(expect (cider--version) :to-equal "0.11.0snapshot (package: 20160301.2217)")))
Expand Down

0 comments on commit 096c184

Please sign in to comment.