 
 (defn- clone-repo
   "Clones the latest version of the specified repo from GIT."
-  ([branch repo-name]
+  ([repo-name branch]
      (info "First ensuring that repository directory does not exist")
-     (rm "-rf" (repo-path repo-name))
-     (info "Cloning repository to" (repo-path repo-name))
+     (rm "-rf" (repo-path repo-name branch))
+     (info "Cloning repository to" (repo-path repo-name branch))
      (->
       (Git/cloneRepository)
       (.setURI (repo-url repo-name))
-      (.setDirectory (as-file (repo-path repo-name)))
+      (.setDirectory (as-file (repo-path repo-name branch)))
       (.setRemote "origin")
       (.setBranch branch)
       (.setBare false)


(defn create-application
  [name]
  (setup-repository name)
  (doseq [branch valid-environments]
    (setup-branch name branch))
  {:name name
   :path (str base-git-url name)
   :branches valid-environments})


(defn- pull-repo
  "Pull a repository by pulling."
  [repo-name branch]
  (let [git (Git/open (as-file (repo-path repo-name branch)))]
    (info "Fetching repository to" (repo-path repo-name branch))
    (->
     (.pull git)
     (.call))
