Permalink
Browse files

'First commit.'

  • Loading branch information...
0 parents commit e10f5d9a07a83cc705ef94848d0b84b0f540db80 @Raynes committed Apr 30, 2012
Showing with 75 additions and 0 deletions.
  1. +10 −0 .gitignore
  2. +25 −0 README.md
  3. +7 −0 project.clj
  4. +33 −0 src/leiningen/gitify.clj
@@ -0,0 +1,10 @@
+/target
+/lib
+/classes
+/checkouts
+pom.xml
+*.jar
+*.class
+.lein-deps-sum
+.lein-failures
+.lein-plugins
@@ -0,0 +1,25 @@
+# lein-gitify
+
+A Leiningen plugin to do many wonderful things.
+
+## Usage
+
+FIXME: Use this for user-level plugins:
+
+Put `[lein-gitify "0.1.0-SNAPSHOT"]` into the `:plugins` vector of your
+`:user` profile, or if you are on Leiningen 1.x do `lein plugin install
+lein-gitify 0.1.0-SNAPSHOT`.
+
+FIXME: Use this for project-level plugins:
+
+Put `[lein-gitify "0.1.0-SNAPSHOT"]` into the `:plugins` vector of your project.clj.
+
+FIXME: and add an example usage that actually makes sense:
+
+ $ lein gitify
+
+## License
+
+Copyright © 2012 FIXME
+
+Distributed under the Eclipse Public License, the same as Clojure.
@@ -0,0 +1,7 @@
+(defproject lein-gitify "0.1.0"
+ :description "A leiningen plugin for gitifying a plugin."
+ :url "https://github.com/Raynes/lein-gitify"
+ :license {:name "Eclipse Public License"
+ :url "http://www.eclipse.org/legal/epl-v10.html"}
+ :dependencies [[tentacles "0.1.4"]]
+ :eval-in-leiningen true)
@@ -0,0 +1,33 @@
+(ns leiningen.gitify
+ (:require [leiningen.core.main :refer [abort]]
+ [clojure.string :refer [trim-newline]]
+ [tentacles.repos :refer [create-repo]]
+ [clojure.java.shell :refer [sh]]
+ [clojure.pprint :refer [pprint]]))
+
+(defn gitify [project & args]
+ (let [user (trim-newline (:out (sh "git" "config" "--get" "github.user")))
+ pass (trim-newline (:out (sh "git" "config" "--get" "github.password")))
+ name (:name project)
+ args (set args)]
+ (if (and user pass)
+ (do (println "Creating a Github repository...")
+ (let [response (create-repo name {:auth [user pass]
+ :description (:description project)
+ :homepage (:url project)
+ :public (not (args "--private"))})]
+ (if (:status response)
+ (do (pprint response)
+ (println "\nCould not create the repository."))
+ (do (println "Creating a git repository in this directory...")
+ (println (:out (sh "git" "init")))
+ (println "Setting up a remote, origin, to point at the new Github repo...")
+ (sh "git" "remote" "add" "origin" (str "git@github.com:" user "/" name ".git"))
+ (when (args "--init")
+ (println "Pushing first commit...")
+ (sh "git" "add" ".")
+ (println (:out (sh "git" "commit" "-m 'First commit.'")))
+ (println (:out (sh "git" "push" "origin" "master"))))))))
+ (abort "Please github.user and github.password (using git"
+ "config) and try again."))
+ (println "Done! Code away!")))

0 comments on commit e10f5d9

Please sign in to comment.