Skip to content

Loading…

Alternate repo root #872

Merged
merged 1 commit into from

2 participants

@dgrnbrg

This is the correct pull request to be associated with issue #869

@dgrnbrg

I don't understand why @hugoduncan's commit is in this pull request, since it appears to already be merged into master. I am very confused now.

I have testing my patch, and it worked in that it added the :scm metadata to the pom.xml for a subproject.

@dgrnbrg dgrnbrg Allow project's git repository to be different than project root
This allows for other directories to be used for the automatic
repository tagging. This is useful for repositories that contain
multiple projects, such as leiningen-core and leiningen, so that both
will have the correct repository tag information in their pom.xml.
80cf398
@technomancy
Owner

Looks good; thank you.

@technomancy technomancy merged commit b4c5fe5 into technomancy:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 28, 2012
  1. @dgrnbrg

    Allow project's git repository to be different than project root

    dgrnbrg committed
    This allows for other directories to be used for the automatic
    repository tagging. This is useful for repositories that contain
    multiple projects, such as leiningen-core and leiningen, so that both
    will have the correct repository tag information in their pom.xml.
Showing with 17 additions and 9 deletions.
  1. +1 −0 leiningen-core/project.clj
  2. +7 −1 sample.project.clj
  3. +9 −8 src/leiningen/pom.clj
View
1 leiningen-core/project.clj
@@ -11,6 +11,7 @@
[com.cemerick/pomegranate "0.0.13"
:exclusions [org.slf4j/slf4j-api]]]
:repositories [["classic" "https://clojars.org/repo/"]]
+ :scm {:dir ".."}
;; This is only used when releasing Leiningen. Can't put it in a
;; profile since it must be installed using lein1
;;:aot :all
View
8 sample.project.clj
@@ -265,7 +265,13 @@
;; Include <scm> tag in generated pom.xml file. All key/value pairs
;; appear exactly as configured. If absent, Leiningen will try to
;; use information from a .git directory.
- :scm {:name "git" :tag "098afd745bcd" :url "http://127.0.0.1/git/my-project"}
+ :scm {:name "git"
+ :tag "098afd745bcd"
+ :url "http://127.0.0.1/git/my-project"
+ ;; Allows you to use a repository in a different directory than the
+ ;; project's root, for instance, if you had multiple projects in a
+ ;; single git repository.
+ :dir ".."}
;; include arbitrary xml in generated pom.xml file
:pom-addition [:developers [:developer [:name "My Name"]]])
View
17 src/leiningen/pom.clj
@@ -20,12 +20,13 @@
;; git scm
-(defn- resolve-git-dir [git-dir]
- (let [git-dir-file (io/file git-dir)]
- (cond
- (.isDirectory git-dir-file) git-dir-file
- (.isFile git-dir-file) (io/file (second (re-find #"gitdir: (\S+)" (slurp (str git-dir-file)))))
- :else git-dir)))
+(defn- resolve-git-dir [project]
+ (let [alternate-git-root (io/file (get-in project [:scm :dir]))
+ git-dir-file (io/file (or alternate-git-root (:root project)) ".git")]
+ (if
+ (.isFile git-dir-file)
+ (io/file (second (re-find #"gitdir: (\S+)" (slurp (str git-dir-file)))))
+ git-dir-file)))
(defn- read-git-ref
"Reads the commit SHA1 for a git ref path."
@@ -110,7 +111,7 @@
Retains backwards compatibility without an :scm map."
(if
(= "auto" scm)
- (make-git-scm (resolve-git-dir (io/file (:root project) ".git")))
+ (make-git-scm (resolve-git-dir project))
(xml-tags :scm (xmlify (select-keys (:scm project)
[:url :connection
:tag :developerConnection])))))
@@ -337,7 +338,7 @@
(.setProperty "version" (:version project))
(.setProperty "groupId" (:group project))
(.setProperty "artifactId" (:name project)))
- git-head (resolve-git-dir (io/file (:root project) ".git"))]
+ git-head (resolve-git-dir project)]
(when (.exists git-head)
(.setProperty properties "revision" (read-git-head git-head)))
(.store properties baos "Leiningen"))
Something went wrong with that request. Please try again.