   (:require [leiningen.utils :as u]
             [clojure.java.shell :as sh]
             [leiningen.core.main :as m]
-            [clojure.pprint :as pp]))
+            [clojure.pprint :as pp]
+            [clojure.string :as str]))
 
 (def output-length 120)
 

  (let [changes (get-changed-files)]
    (if (empty? changes)
      {:project project :diff :no-change}
      {:project project :diff changes})))

(defn pull-rebase! [project]
  (let [pull-result (sh/sh "git" "pull" "-r")]

  (u/output-of (sh/sh "git" "log" "-1" "--format=%cr" path) ""))

(defn get-changed-files []
  (let [result (sh/sh "git" "diff" "--name-only")]
    (if (u/is-success? result)
      (->> (u/output-of result)
           (str/split-lines)
           (remove empty?))
      [])))

(defn add [path]
  (let [result (sh/sh "git" "add" path)]
    (if (u/is-success? result)
      {:status :added}
      {:status :failed})))

(defn unpushed-commit []
  (u/output-of (sh/sh "git" "diff" "origin/master..HEAD" "--name-only")))
