Skip to content
Browse files

Handle paths beginning with ~ correctly.

  • Loading branch information...
1 parent d04857c commit 65b99222f8dcb78983ac618a8bb0ece08da67dfc @technomancy committed May 12, 2011
Showing with 12 additions and 1 deletion.
  1. +8 −1 src/quick/beam.clj
  2. +4 −0 test/quick/test/beam.clj
View
9 src/quick/beam.clj
@@ -4,8 +4,15 @@
(org.eclipse.jgit.revwalk RevWalk)
(org.eclipse.jgit.storage.file FileRepository)))
+(defn absolutize [path]
+ (-> (if (.startsWith path "~")
+ (apply str (System/getProperty "user.home") (rest path))
+ path)
+ (io/file)
+ .getAbsolutePath))
+
(defn find-repo [path]
- (when-let [git-dir (->> (.getAbsoluteFile (io/file path))
+ (when-let [git-dir (->> (absolutize path)
(iterate #(.getParentFile %))
(take-while identity)
(map #(io/file % ".git"))
View
4 test/quick/test/beam.clj
@@ -8,3 +8,7 @@
(is (not (history "/tmp")))
(doseq [c (history)]
(is (every? c [:author :message :sha :date]))))
+
+(deftest test-absolutize
+ (is (re-find #"(/home|/Users)/\w+/src/quickbeam"
+ (absolutize "~/src/quickbeam"))))

0 comments on commit 65b9922

Please sign in to comment.
Something went wrong with that request. Please try again.