Skip to content

Commit

Permalink
revision-sha: only create git-version in resources when git/revision-…
Browse files Browse the repository at this point in the history
…sha is successful

This allow to run standalone/uberjar in a directory with no .git information
  • Loading branch information
bcachet committed Nov 7, 2023
1 parent ce87a95 commit 409afaa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
16 changes: 10 additions & 6 deletions src/exoscale/tools/project/api.clj
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,16 @@

(defn revision-sha
[opts]
(let [{:exoscale.tools.project.api.tasks/keys [dir]} opts
git-version-file (str (fs/path dir "resources" "git-version"))]
(fs/create-dirs (fs/path dir "resources"))
(spit git-version-file (git/revision-sha opts))
(println "storing git sha in" git-version-file)
opts))
(try
(let [revision-sha (git/revision-sha opts)
{:exoscale.tools.project.api.tasks/keys [dir]} opts
git-version-file (str (fs/path dir "resources" "git-version"))]
(fs/create-dirs (fs/path dir "resources"))
(spit git-version-file revision-sha)
(println "storing git sha in" git-version-file)
opts)
(catch Exception e
(println (format "failed to retrieve git version %s" (ex-message e))))))

(defn revision-version
[opts]
Expand Down
6 changes: 3 additions & 3 deletions src/exoscale/tools/project/api/tasks.clj
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,13 @@
(flush)
(System/exit 1))

(when-not task
(println (format "Task '%s' not found" id))
(when-not task-def
(println (format "Task '%s' not found" task-id))
(System/exit 1))

(println "starting task:" task-id
(if lib
(str "for:" lib)
(str "for: " lib)
"from `root`"))
(flush)

Expand Down

0 comments on commit 409afaa

Please sign in to comment.