        :branch     (clojure.string/trim (nth parsed 2))})))
 
 (defn parse-job-names
+  "Parse all job names, try to get group, repository, and branch from them."
   [branch-job-prefix job-names]
   (for [job-name job-names]
        (parse-job-name branch-job-prefix job-name)))
 
 (defn create-or-delete-jenkins-job
+  "Create or delete Jenkins job according to selected action."
   [jenkins-url job-list-command branch-job-prefix action]
   (log/info "Create-or-delete-jenkins-job")
   (let [reponame       (:name action)

  (file-utils/slurp- (:body request)))

(defn log-request
  [request]
  (log/info "Handling request: " (:uri request) (:remote-addr request))
  (if verbose
    (clojure.pprint/pprint request)))

(defn send-response
  [response-text]
  (-> (http-response/response response-text)
      (http-response/content-type "text/html")))

(defn parse-gitlab-info
  [request]
  (let [body (read-request-body request)]
    (if body
      (json/read-str body :key-fn clojure.core/keyword))))

(defn repo-workdir
  [workdir group reponame]
  (string/join "/" [workdir group reponame]))

(defn repodir-exists?
  [workdir group reponame]
  (let [f (new java.io.File (repo-workdir workdir group reponame))]
    (.isDirectory f)))

(defn fetch-mirror-repo
  [workdir group reponame repository-url]
  (log/info "Fetching mirror repository" repository-url)
  ; TODO test --prune
  (shell/sh "git" "--git-dir" (repo-workdir workdir group reponame) "fetch"))

(defn clone-mirror-repo
  [workdir group reponame repository-url]
  (log/info "Cloning mirror repository" repository-url)
  (shell/sh "git"

(require '[clj-fileutils.fileutils :as file-utils])
(require '[clj-jenkins-api.jenkins-api :as jenkins-api])

(def verbose
  "Flag to enable or disable verbosity level."
  false)

(def port
  "Default port for the service."
  3000)

(def workdir
  "Working directory."
  "/tmp/bare-repositories")

(def job-list-command
  "Command used to retrieve job list from Jenkins."
  "/api/json?tree=jobs[name]")

(def branch-job-prefix
  "Prefix used for all 'branch' build jobs."
  "branch-")

(def jenkins-url
  "URL to Jenkins server."
  (System/getenv "JENKINS_URL"))

(defn read-request-body
  "Read all informations from the request body."
