<commit_before>(ns github-changelog.semver
  (:require [clj-semver.core :as semver]
            [clojure.spec.alpha :as s]
            [clojure.spec.gen.alpha :as gen]
            [clojure.string :as str]
            [github-changelog.spec :as spec]))

(defn- map->str [{:keys [major minor patch pre-release build]}]
  (cond-> (str/join \. [major minor patch])
    pre-release (str "-" pre-release)
    build (str "+" build)))

(def nat-int (s/with-gen
               nat-int?
               #(gen/int)))

(s/def ::major nat-int)
(s/def ::minor nat-int)
(s/def ::patch nat-int)

(s/def ::pre-release (s/with-gen
                       (s/nilable ::spec/non-blank-string)
                       gen/string-alphanumeric))

(s/def ::build (s/with-gen
                 (s/nilable ::spec/non-blank-string)
                 gen/string-alphanumeric))

(s/def ::version
  (s/keys :req-un [::major ::minor ::patch]
          :opt-un [::pre-release ::build]))

(s/def ::version-string
  (s/with-gen
    semver/valid-format?
    #(gen/fmap map->str (s/gen ::version))))

(s/def ::version-or-string (s/or :version ::version
                                 :string ::version-string))

(s/def ::types #{:major :minor :patch :pre-release :build})

(def newer? semver/newer?)

(s/fdef newer?
  :args (s/cat :a ::version-or-string :b ::version-or-string)
  :ret boolean?)

(def valid? semver/valid?)

(s/fdef valid?
  :args (s/cat :v any?)
  :ret boolean?)
<commit_msg>Disable generators for newer?<commit_after>(ns github-changelog.semver
  (:require [clj-semver.core :as semver]
            [clojure.spec.alpha :as s]
            [clojure.spec.gen.alpha :as gen]
            [clojure.string :as str]
            [github-changelog.spec :as spec]))

(defn- map->str [{:keys [major minor patch pre-release build]}]
  (cond-> (str/join \. [major minor patch])
    pre-release (str "-" pre-release)
    build (str "+" build)))

(def nat-int (s/with-gen
               nat-int?
               #(gen/int)))

(s/def ::major nat-int)
(s/def ::minor nat-int)
(s/def ::patch nat-int)

(s/def ::pre-release (s/with-gen
                       (s/nilable ::spec/non-blank-string)
                       gen/string-alphanumeric))

(s/def ::build (s/with-gen
                 (s/nilable ::spec/non-blank-string)
                 gen/string-alphanumeric))

(s/def ::version
  (s/keys :req-un [::major ::minor ::patch]
          :opt-un [::pre-release ::build]))

(s/def ::version-string
  (s/with-gen
    semver/valid-format?
    #(gen/fmap map->str (s/gen ::version))))

(s/def ::version-or-string (s/or :version ::version
                                 :string ::version-string))

(s/def ::types #{:major :minor :patch :pre-release :build})

;; TODO: https://github.com/grimradical/clj-semver/issues/7
(def ^:no-gen newer? semver/newer?)

(s/fdef newer?
  :args (s/cat :a ::version-or-string :b ::version-or-string)
  :ret boolean?)

(def valid? semver/valid?)

(s/fdef valid?
  :args (s/cat :v any?)
  :ret boolean?)

{'fraction_non_alphanumeric': 0.18254764292878636, 'fraction_numerical': 0.00033433634236041456, 'mean_word_length': 2.2557127312295973, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2207762', 'n_tokens_mistral': 1091, 'n_tokens_neox': 1079, 'n_words': 244}