<commit_before>(ns docker-clojure.manifest
  (:require [clojure.string :as str]
            [docker-clojure.dockerfile :as df]
            [docker-clojure.util :refer [docker-tag full-docker-tag]]))

(defn variant-tags
  "Generates all the Docker Hub tag variations for the given variant"
  [variant]
  (let [short-tag (:docker-tag variant)
        full-tag  (full-docker-tag variant)
        base      (into #{} [short-tag full-tag])]
    (conj base
          (docker-tag {:omit-jdk? true} variant)
          (docker-tag {:omit-build-tool? true} variant)
          (docker-tag {:omit-build-tool-version? true} variant)
          (docker-tag {:omit-distro? true} variant))))

(defn variant->manifest
  [variant]
  (str/join "\n"
            (conj
              (remove nil? [(str/join " " (conj ["Tags:"] (str/join ", " (variant-tags variant))))
                            (when-let [arch (:architectures variant)]
                              (str/join " " ["Architectures:" (str/join ", " arch)]))
                            (str/join " " ["Directory:" (df/build-dir variant)])])
              nil)))

(defn generate
  "Generates Docker manifest file for a given git commit and returns it as a
  string."
  [{:keys [maintainers architectures git-repo]} git-commit variants]
  (let [maintainers-label "Maintainers:"
        maintainers-sep (apply str ",\n" (repeat (inc (count maintainers-label)) " "))]
    (str/join "\n"
              (concat
                [(str/join " " [maintainers-label
                                (str/join maintainers-sep maintainers)])
                 (str/join " " ["Architectures:" (str/join ", " architectures)])
                 (str/join " " ["GitRepo:" git-repo])
                 (str/join " " ["GitCommit:" git-commit])]

                (map variant->manifest variants)

                [nil]))))
<commit_msg>Try to ensure consistent sorting of tags in manifest<commit_after>(ns docker-clojure.manifest
  (:require [clojure.string :as str]
            [docker-clojure.dockerfile :as df]
            [docker-clojure.util :refer [docker-tag full-docker-tag]]))

(defn variant-tags
  "Generates all the Docker Hub tag variations for the given variant"
  [variant]
  (let [short-tag (:docker-tag variant)
        full-tag  (full-docker-tag variant)
        base      (into #{} [short-tag full-tag])]
    (-> base
        (conj
          (docker-tag {:omit-jdk? true} variant)
          (docker-tag {:omit-build-tool? true} variant)
          (docker-tag {:omit-build-tool-version? true} variant)
          (docker-tag {:omit-distro? true} variant))
        vec
        sort)))

(defn variant->manifest
  [variant]
  (str/join "\n"
            (conj
              (remove nil? [(str/join " " (conj ["Tags:"]
                                                (->> variant
                                                     variant-tags
                                                     (str/join ", "))))
                            (when-let [arch (:architectures variant)]
                              (str/join " " ["Architectures:" (str/join ", " arch)]))
                            (str/join " " ["Directory:" (df/build-dir variant)])])
              nil)))

(defn generate
  "Generates Docker manifest file for a given git commit and returns it as a
  string."
  [{:keys [maintainers architectures git-repo]} git-commit variants]
  (let [maintainers-label "Maintainers:"
        maintainers-sep (apply str ",\n" (repeat (inc (count maintainers-label)) " "))]
    (str/join "\n"
              (concat
                [(str/join " " [maintainers-label
                                (str/join maintainers-sep maintainers)])
                 (str/join " " ["Architectures:" (str/join ", " architectures)])
                 (str/join " " ["GitRepo:" git-repo])
                 (str/join " " ["GitCommit:" git-commit])]

                (map variant->manifest variants)

                [nil]))))

{'fraction_non_alphanumeric': 0.14271229404309252, 'fraction_numerical': 0.0, 'mean_word_length': 1.7498257839721254, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4250181', 'n_tokens_mistral': 1192, 'n_tokens_neox': 1106, 'n_words': 288}