Skip to content

Commit

Permalink
Fix up handling of shell output to match up with the "new" clojure.ja…
Browse files Browse the repository at this point in the history
…va.shell
  • Loading branch information
tomfaulhaber committed Oct 30, 2010
1 parent 38b5401 commit 140fa17
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/autodoc/branches.clj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

(defn system [& args]
(pprint args)
(println (apply sh (build-sh-args args))))
(println (:out (apply sh (build-sh-args args)))))

(defn switch-branches
"Switch to the specified branch"
Expand Down
16 changes: 8 additions & 8 deletions src/autodoc/build_html.clj
Original file line number Diff line number Diff line change
Expand Up @@ -264,16 +264,16 @@ looks in the base template directory."
"No usage documentation available")))

(def
#^{:doc "Gets the commit hash for the last commit that included this file. We
#^{:doc "Gets the commit hash for the last commit that included this file. We
do this for source links so that we don't change them with every commit (unless that file
actually changed). This reduces the amount of random doc file changes that happen."}
get-last-commit-hash
(memoize
(fn [file branch]
(let [hash (.trim (sh "git" "rev-list" "--max-count=1" "HEAD" file
:dir (params :root)))]
(when (not (.startsWith hash "fatal"))
hash)))))
get-last-commit-hash
(memoize
(fn [file branch]
(let [hash (.trim (:out (sh "git" "rev-list" "--max-count=1" "HEAD" file
:dir (params :root))))]
(when (not (.startsWith hash "fatal"))
hash)))))

(defn web-src-file [file branch]
(when-let [web-src-dir (params :web-src-dir)]
Expand Down
2 changes: 1 addition & 1 deletion src/autodoc/doc_files.clj
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ transformations along the way."
[src-file dst relative]
(spit
(File. (File. dst) (.replaceFirst relative "\\.markdown$" ".html"))
(sh "markdown" (.getPath src-file))))
(:out (sh "markdown" (.getPath src-file)))))

(defn xform-tree
"Takes source and destination directories and copies the source to the destination,
Expand Down
16 changes: 8 additions & 8 deletions src/autodoc/git_tools.clj
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ root of a git repo)"
(with-sh-dir dir
(when-let [branch-str (first
(filter #(.startsWith % "*")
(.split (sh "git" "branch") "\n")))]
(.split (:out (sh "git" "branch")) "\n")))]
(.substring branch-str 2))))

(defn has-remote?
"return true if there is a remote called origin that we could push back to"
[dir]
(with-sh-dir dir
(some #(= % "origin") (.split (sh "git" "remote") "\n"))))
(some #(= % "origin") (.split (:out (sh "git" "remote")) "\n"))))

(defn stage-new-doc-files
"Add any new supplementary documents to the git staging area"
Expand All @@ -41,7 +41,7 @@ root of a git repo)"
(map #(.getPath (File. (File. %) "doc"))
(cons "." (map branch-subdir (next branches)))))]
(with-sh-dir dir
(println (apply sh "git" "add" "-v" dirs)))))
(println (:out (apply sh "git" "add" "-v" dirs))))))

(defn stage-new-api-files
"Add any new API namespace files to the git staging area"
Expand All @@ -50,19 +50,19 @@ root of a git repo)"
(filter #(.endsWith (.getPath %) "-api.html")
(file-seq dir)))]
(with-sh-dir dir
(println (apply sh "git" "add" "-v" files)))))
(println (:out (apply sh "git" "add" "-v" files))))))

(defn stage-modified-files
"Add any changed files to the git staging area"
[dir]
(with-sh-dir dir
(println (sh "git" "add" "-u" "-v" "."))))
(println (:out (sh "git" "add" "-u" "-v" ".")))))

(defn git-hash
"Get the git hash for the head of the given branch (or tag)"
[dir head len]
(with-sh-dir dir
(.substring (.trim (sh "git" "rev-parse" head)) 0 len)))
(.substring (.trim (:out (sh "git" "rev-parse" head))) 0 len)))

(defn comment-for
"Construct a git comment for all the appropriate branches"
Expand All @@ -76,13 +76,13 @@ root of a git repo)"
"Commit the staged files in dir (a java.io.File)."
[dir comment]
(with-sh-dir dir
(println (sh "git" "commit" "-m" comment))))
(println (:out (sh "git" "commit" "-m" comment)))))

(defn git-push
"Push the commit to a remote, if defined"
[dir]
(with-sh-dir dir
(println (sh "git" "push" "origin" (current-branch dir)))))
(println (:out (sh "git" "push" "origin" (current-branch dir))))))

(defn autodoc-commit [src-dir doc-dir branches]
"Stage and commit all new and changed files in the autodoc tree"
Expand Down

0 comments on commit 140fa17

Please sign in to comment.