Skip to content

Commit

Permalink
Do not create git stash if there are no local changes on CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
jeisses committed Mar 1, 2023
1 parent 862d83f commit 7c42840
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/nosana_node/pipeline.clj
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,29 @@
nos/build
(assoc :default-args (:nos-default-args conf)))))

(defn has-local-git-changes? [dir untracked-files?]
(-> (sh/sh "git"
"-C" dir
"status"
"--porcelain"
"--untracked-files" (if untracked-files? "yes" "no"))
:out
string/blank?
not))

(defn make-local-git-artifact! [dir artifact-name flow-id commit]
(println "Creating artifact " )
(let [artifact (str dir "/.nos/artifacts/" artifact-name)
_ (io/make-parents artifact)
stash (if commit
commit
stash (cond
(and commit (has-local-git-changes? dir false))
(-> (sh/sh "git" "-C" dir "stash" "create")
:out
(string/replace "\n" "")))
_ (when commit
(println "Created stash " stash " for working directory"))
(string/replace "\n" ""))
(not commit) "HEAD"
:else commit)
_ (when commit
(println "Created stash " stash " for working directory"))

{:keys [err out exit]} (sh/sh "git"
"-C" dir
Expand Down

0 comments on commit 7c42840

Please sign in to comment.