From 0ab5609ccb88f41e2d64b1f6631151507cffed4c Mon Sep 17 00:00:00 2001 From: Klaus Wuestefeld Date: Sat, 18 Jan 2014 21:31:24 -0200 Subject: [PATCH] Bazaar Git spikes --- bazaar/src/bazaar/core.clj | 70 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 68 insertions(+), 2 deletions(-) diff --git a/bazaar/src/bazaar/core.clj b/bazaar/src/bazaar/core.clj index db6617314..4d17f092b 100644 --- a/bazaar/src/bazaar/core.clj +++ b/bazaar/src/bazaar/core.clj @@ -1,5 +1,71 @@ (ns bazaar.core (:use [clj-jgit.porcelain])) -(def my-repo - (git-clone-full "https://github.com/semperos/clj-jgit.git" "local-folder/clj-jgit")) \ No newline at end of file +(with-identity {"trash" {}} + (def my-clone + (git-clone-full "git@github.com:klauswuestefeld/trash.git" "trash"))) + +(-> (:fetch-result my-repo) .getClass .getMethods seq) + +(def pull-result (.call (.pull (:repo my-repo)))) +(.isSuccessful pull-result) + + +(def repo (:fetch-result my-clone)) +(.getMessages repo) +(.getURI repo) +(-> (:repo my-repo) .getClass .getMethods seq) +my-repo +(def my-repo (:repo my-clone)) + +(use 'clojure.java.io) +(.getAbsolutePath (file "~/git/tmptmp")) + +(git-status my-repo) +;=> {:untracked #{}, :removed #{}, :modified #{}, :missing #{}, :changed #{}, :added #{}} + +;; List existing branches +(git-branch-list my-repo) +;=> (#) + +;; Create a new local branch to store our changes +(git-branch-create my-repo "my-branch") +;=> # + +;; Prove to ourselves that it was created +(git-branch-list my-repo) +;=> (# #) + +;; Check out our new branch + +(git-checkout my-repo "my-branch") +;=> # + +;; Now go off and make your changes. +;; For example, let's say we added a file "foo.txt" at the base of the project. +(git-status my-repo) +;=> {:untracked #{"foo.txt"}, :removed #{}, :modified #{}, :missing #{}, :changed #{}, :added #{}} + +;; Add the file to the index +(git-add my-repo "whatever.txt") +;=> # + +;; Check for status change +(git-status my-repo) +;=> {:untracked #{}, :removed #{}, :modified #{}, :missing #{}, :changed #{}, :added #{"foo.txt"}} + +;; Now commit your changes, specifying author and committer if desired +(git-commit my-repo "Add a file" {:name "Fulano" :email "fulano@example.com"}) +;=> # + + +;; Status clean +(git-status my-repo) +;=> {:untracked #{}, :removed #{}, :modified #{}, :missing #{}, :changed #{}, :added #{}} + +(git-clean my-repo :clean-dirs? true, :ignore? true) + +(first (git-log my-repo)) + +(with-identity {"trash" {}} + (-> my-repo .push .call)) \ No newline at end of file