Skip to content

Commit 223f0c2

Browse files
committed
merge master
2 parents 9c546a6 + 3e1ccd2 commit 223f0c2

File tree

6 files changed

+39
-61
lines changed

6 files changed

+39
-61
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
Changelog
22
===========
33

4+
* 2.0.119 on Mar 10, 2021
5+
* Fix issues with checkouts of multiple commits per repo
6+
* resolve now only fetches if it can't resolve a ref
7+
* Config read from most to least preferred: Java system property / env var / default:
8+
* gitlibs dir: `clojure.gitlibs.dir` / `GITLIBS` / `nil`
9+
* git command: `clojure.gitlibs.command` / `GITLIBS_COMMAND` / `"git"`
10+
* Fix reflection error
11+
* 2.0.109 on Mar 3, 2021
12+
* TDEPS-91 Replace jgit implementation by shelling out to git
413
* 1.0.100 on Aug 20, 2020
514
* Fetch all tags on procure
615
* 1.0.96 on Aug 7, 2020

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ The following git url types are supported:
2727

2828
### SSH authentication for private repositories
2929

30-
ssh authentication works by connecting to the local ssh agent (ssh-agent on *nix or Pageant via PuTTY on Windows).
30+
ssh authentication works by connecting to the local ssh agent (ssh-agent on \*nix or Pageant via PuTTY on Windows).
3131
The ssh-agent must have a registered identity for the key being used to access the Git repository.
3232
To check whether you have registered identities, use:
3333

@@ -83,10 +83,10 @@ The cache location can also be set with the environment variable GITLIBS.
8383

8484
This project follows the version scheme MAJOR.MINOR.COMMITS where MAJOR and MINOR provide some relative indication of the size of the change, but do not follow semantic versioning. In general, all changes endeavor to be non-breaking (by moving to new names rather than by breaking existing names). COMMITS is an ever-increasing counter of commits since the beginning of this repository.
8585

86-
Latest release: 1.0.100
86+
Latest release: 2.0.119
8787

8888
* [All released versions](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.clojure%22%20AND%20a%3A%22tools.gitlibs%22)
89-
* Coordinates: `org.clojure/tools.gitlibs {:mvn/version "1.0.100"}`
89+
* Coordinates: `org.clojure/tools.gitlibs {:mvn/version "2.0.119"}`
9090

9191
# Developer Information
9292

@@ -99,7 +99,7 @@ Latest release: 1.0.100
9999

100100
# Copyright and License
101101

102-
Copyright © 2018-2020 Rich Hickey, Alex Miller, and contributors
102+
Copyright © 2018-2021 Rich Hickey, Alex Miller, and contributors
103103

104104
All rights reserved. The use and
105105
distribution terms for this software are covered by the

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
22
<modelVersion>4.0.0</modelVersion>
33
<artifactId>tools.gitlibs</artifactId>
4-
<version>2.0.110-SNAPSHOT</version>
4+
<version>2.0.120-SNAPSHOT</version>
55
<name>tools.gitlibs</name>
66

77
<parent>

src/main/clojure/clojure/tools/gitlibs.clj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,10 @@
111111
@(future (procure "https://github.com/clojure/tools.gitlibs.git" 'org.clojure/tools.gitlibs "11fc77496f013871c8af3514bbba03de0af28061"))
112112
@(future (procure "https://github.com/clojure/tools.gitlibs.git" 'org.clojure/tools.gitlibs "11fc77496f013871c8af3514bbba03de0af28061")))
113113

114+
(println
115+
@(future (procure "https://github.com/cognitect-labs/test-runner.git" 'cognitect-labs/test-runner "b6b3193fcc42659d7e46ecd1884a228993441182"))
116+
@(future (procure "https://github.com/cognitect-labs/test-runner.git" 'cognitect-labs/test-runner "cb96e80f6f3d3b307c59cbeb49bb0dcb3a2a780b"))
117+
@(future (procure "https://github.com/cognitect-labs/test-runner.git" 'cognitect-labs/test-runner "9e1098965f2089c8cf492d23c0b7520f8690440a")))
118+
114119
(tags "https://github.com/clojure/tools.gitlibs.git" {:print-commands true})
115-
)
120+
)

src/main/clojure/clojure/tools/gitlibs/impl.clj

Lines changed: 14 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
[clojure.java.io :as jio]
1313
[clojure.string :as str])
1414
(:import
15-
[java.io File FilenameFilter IOException]
16-
[java.nio.file Files CopyOption StandardCopyOption AtomicMoveNotSupportedException]
17-
[java.nio.file.attribute FileAttribute]))
15+
[java.io File FilenameFilter IOException]))
1816

1917
(set! *warn-on-reflection* true)
2018

@@ -65,7 +63,7 @@
6563
@CACHE)
6664

6765
(def ^:private COMMAND_CACHE
68-
(delay (read-config "clojure.gitlibs.command" "GITLIBS_CMD" "git")))
66+
(delay (read-config "clojure.gitlibs.command" "GITLIBS_COMMAND" "git")))
6967

7068
(defn git-command
7169
"Path to git command to run"
@@ -89,14 +87,12 @@
8987
^File [url]
9088
(jio/file (cache-dir) "_repos" (clean-url url)))
9189

92-
;; git clone --bare --quiet URL PATH
93-
;; git --git-dir <> fetch
94-
;; git --git-dir <> --work-tree <dst> checkout <rev>
95-
9690
(defn git-fetch
9791
[^File git-dir opts]
9892
(let [git-path (.getCanonicalPath git-dir)
99-
{:keys [exit err] :as ret} (runproc opts (git-command) "--git-dir" git-path "fetch" "--tags")]
93+
{:keys [exit err] :as ret} (runproc opts (git-command)
94+
"--git-dir" git-path
95+
"fetch" "--quiet" "--tags")]
10096
(when-not (zero? exit)
10197
(throw (ex-info (format "Unable to fetch %s%n%s" git-path err) ret)))))
10298

@@ -105,7 +101,8 @@
105101
[url ^File git-dir opts]
106102
(printerrln "Cloning:" url)
107103
(let [git-path (.getCanonicalPath git-dir)
108-
{:keys [exit err] :as ret} (runproc opts (git-command) "clone" "--bare" url git-path)]
104+
{:keys [exit err] :as ret} (runproc opts (git-command)
105+
"clone" "--quiet" "--bare" url git-path)]
109106
(when-not (zero? exit)
110107
(throw (ex-info (format "Unable to clone %s%n%s" git-path err) ret)))
111108
git-dir))
@@ -119,55 +116,20 @@
119116
(git-clone-bare url git-dir-file opts))
120117
(.getCanonicalPath git-dir-file)))
121118

122-
(defonce ^:private no-file-attrs
123-
(into-array FileAttribute []))
124-
125-
(defonce ^:private no-copy-opts
126-
(into-array CopyOption []))
127-
128-
(defonce ^:private atomic-move-opts
129-
(into-array CopyOption [StandardCopyOption/ATOMIC_MOVE]))
130-
131-
(defn- delete-recursive
132-
[^File file]
133-
(when (.isDirectory file)
134-
(run! delete-recursive (.listFiles file)))
135-
(.delete file))
136-
137-
(defn- write-with-temp
138-
[^File parent-dir target write-fn]
139-
(let [target-dir (jio/file parent-dir target)]
140-
(when-not (.exists target-dir)
141-
(when-not (.exists parent-dir)
142-
(.mkdirs parent-dir))
143-
(let [parent-path (.toPath parent-dir)
144-
temp-path (Files/createTempDirectory parent-path (str target "-") no-file-attrs)]
145-
(write-fn (.toString temp-path))
146-
(let [target-path (.toPath target-dir)]
147-
(try
148-
(try
149-
(Files/move temp-path target-path atomic-move-opts)
150-
(catch AtomicMoveNotSupportedException _
151-
(Files/move temp-path target-path no-copy-opts)))
152-
(catch IOException _
153-
(try
154-
(delete-recursive (.toFile temp-path))
155-
(catch Throwable t)))))))))
156-
157119
(defn git-checkout
158120
[git-dir-path ^File lib-dir ^String rev opts]
159121
(let [rev-file (jio/file lib-dir rev)]
160122
(when-not (.exists rev-file)
161-
(write-with-temp lib-dir rev
162-
#(runproc opts
163-
(git-command)
164-
"--git-dir" git-dir-path
165-
"--work-tree" %
166-
"checkout" rev)))))
123+
(runproc opts (git-command)
124+
"--git-dir" git-dir-path
125+
"worktree" "add" "--force" "--detach" "--quiet"
126+
(.getCanonicalPath rev-file) rev))))
167127

168128
(defn git-rev-parse
169129
[git-dir rev opts]
170-
(let [{:keys [exit out]} (runproc opts (git-command) "--git-dir" git-dir "rev-parse" rev)]
130+
(let [{:keys [exit out]} (runproc opts (git-command)
131+
"--git-dir" git-dir
132+
"rev-parse" rev)]
171133
(when (zero? exit)
172134
(str/trimr out))))
173135

src/test/clojure/clojure/tools/test_gitlibs.clj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@
2020
"739c1af56dae621aedf1bb282025a0d676eff713")))
2121

2222
(deftest test-procure
23-
(let [wt (gl/procure repo-url 'org.clojure/spec.alpha "739c1af")]
24-
(is (= wt (.getAbsolutePath (jio/file (glim/cache-dir) "libs" "org.clojure" "spec.alpha" "739c1af56dae621aedf1bb282025a0d676eff713"))))
25-
(is (.exists (jio/file (glim/cache-dir) "_repos" "github.com" "clojure" "spec.alpha")))))
23+
(let [wt1 (gl/procure repo-url 'org.clojure/spec.alpha "739c1af")
24+
wt2 (gl/procure repo-url 'org.clojure/spec.alpha "6a56327")]
25+
(is (.exists (jio/file (glim/cache-dir) "_repos" "github.com" "clojure" "spec.alpha")))
26+
(is (= wt1 (.getAbsolutePath (jio/file (glim/cache-dir) "libs" "org.clojure" "spec.alpha" "739c1af56dae621aedf1bb282025a0d676eff713"))))
27+
(is (= wt2 (.getAbsolutePath (jio/file (glim/cache-dir) "libs" "org.clojure" "spec.alpha" "6a56327446c909db0d11ecf93a3c3d659b739be9"))))))
2628

2729
(deftest test-descendant-fixed
2830
(is (= (gl/descendant repo-url ["607aef0" "739c1af"])

0 commit comments

Comments
 (0)