git.scm 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2017, 2020 Mathieu Othacehe <m.othacehe@gmail.com>
  3. ;;; Copyright © 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
  4. ;;; Copyright © 2021 Kyle Meyer <kyle@kyleam.com>
  5. ;;;
  6. ;;; This file is part of GNU Guix.
  7. ;;;
  8. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  9. ;;; under the terms of the GNU General Public License as published by
  10. ;;; the Free Software Foundation; either version 3 of the License, or (at
  11. ;;; your option) any later version.
  12. ;;;
  13. ;;; GNU Guix is distributed in the hope that it will be useful, but
  14. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. ;;; GNU General Public License for more details.
  17. ;;;
  18. ;;; You should have received a copy of the GNU General Public License
  19. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  20. (define-module (guix git)
  21. #:use-module (git)
  22. #:use-module (git object)
  23. #:use-module (git submodule)
  24. #:use-module (guix i18n)
  25. #:use-module (guix base32)
  26. #:use-module (guix cache)
  27. #:use-module (gcrypt hash)
  28. #:use-module ((guix build utils)
  29. #:select (mkdir-p delete-file-recursively))
  30. #:use-module (guix store)
  31. #:use-module (guix utils)
  32. #:use-module (guix records)
  33. #:use-module (guix gexp)
  34. #:use-module (guix sets)
  35. #:use-module ((guix diagnostics) #:select (leave))
  36. #:use-module (guix progress)
  37. #:use-module (rnrs bytevectors)
  38. #:use-module (ice-9 format)
  39. #:use-module (ice-9 match)
  40. #:use-module (ice-9 ftw)
  41. #:use-module (srfi srfi-1)
  42. #:use-module (srfi srfi-11)
  43. #:use-module (srfi srfi-34)
  44. #:use-module (srfi srfi-35)
  45. #:export (%repository-cache-directory
  46. honor-system-x509-certificates!
  47. url-cache-directory
  48. with-repository
  49. with-git-error-handling
  50. false-if-git-not-found
  51. update-cached-checkout
  52. url+commit->name
  53. latest-repository-commit
  54. commit-difference
  55. commit-relation
  56. git-checkout
  57. git-checkout?
  58. git-checkout-url
  59. git-checkout-branch
  60. git-checkout-commit
  61. git-checkout-recursive?))
  62. (define %repository-cache-directory
  63. (make-parameter (string-append (cache-directory #:ensure? #f)
  64. "/checkouts")))
  65. (define (honor-system-x509-certificates!)
  66. "Use the system's X.509 certificates for Git checkouts over HTTPS. Honor
  67. the 'SSL_CERT_FILE' and 'SSL_CERT_DIR' environment variables."
  68. ;; On distros such as CentOS 7, /etc/ssl/certs contains only a couple of
  69. ;; files (instead of all the certificates) among which "ca-bundle.crt". On
  70. ;; other distros /etc/ssl/certs usually contains the whole set of
  71. ;; certificates along with "ca-certificates.crt". Try to choose the right
  72. ;; one.
  73. (let ((file (letrec-syntax ((choose
  74. (syntax-rules ()
  75. ((_ file rest ...)
  76. (let ((f file))
  77. (if (and f (file-exists? f))
  78. f
  79. (choose rest ...))))
  80. ((_)
  81. #f))))
  82. (choose (getenv "SSL_CERT_FILE")
  83. "/etc/ssl/certs/ca-certificates.crt"
  84. "/etc/ssl/certs/ca-bundle.crt")))
  85. (directory (or (getenv "SSL_CERT_DIR") "/etc/ssl/certs")))
  86. (and (or file
  87. (and=> (stat directory #f)
  88. (lambda (st)
  89. (> (stat:nlink st) 2))))
  90. (begin
  91. (set-tls-certificate-locations! directory file)
  92. #t))))
  93. (define %certificates-initialized?
  94. ;; Whether 'honor-system-x509-certificates!' has already been called.
  95. #f)
  96. (define-syntax-rule (with-libgit2 thunk ...)
  97. (begin
  98. ;; XXX: The right thing to do would be to call (libgit2-shutdown) here,
  99. ;; but pointer finalizers used in guile-git may be called after shutdown,
  100. ;; resulting in a segfault. Hence, let's skip shutdown call for now.
  101. (libgit2-init!)
  102. (unless %certificates-initialized?
  103. (honor-system-x509-certificates!)
  104. (set! %certificates-initialized? #t))
  105. thunk ...))
  106. (define* (url-cache-directory url
  107. #:optional (cache-directory
  108. (%repository-cache-directory))
  109. #:key recursive?)
  110. "Return the directory associated to URL in %repository-cache-directory."
  111. (string-append
  112. cache-directory "/"
  113. (bytevector->base32-string
  114. (sha256 (string->utf8 (if recursive?
  115. (string-append "R:" url)
  116. url))))))
  117. (define (show-progress progress)
  118. "Display a progress bar as we fetch Git code. PROGRESS is an
  119. <indexer-progress> record from (git)."
  120. (define total
  121. (indexer-progress-total-objects progress))
  122. (define hundredth
  123. (match (quotient (indexer-progress-total-objects progress) 100)
  124. (0 1)
  125. (x x)))
  126. (define-values (done label)
  127. (if (< (indexer-progress-received-objects progress) total)
  128. (values (indexer-progress-received-objects progress)
  129. (G_ "receiving objects"))
  130. (values (indexer-progress-indexed-objects progress)
  131. (G_ "indexing objects"))))
  132. (define %
  133. (* 100. (/ done total)))
  134. (when (and (< % 100) (zero? (modulo done hundredth)))
  135. (erase-current-line (current-error-port))
  136. (let ((width (max (- (current-terminal-columns)
  137. (string-length label) 7)
  138. 3)))
  139. (format (current-error-port) "~a ~3,d% ~a"
  140. label (inexact->exact (round %))
  141. (progress-bar % width)))
  142. (force-output (current-error-port)))
  143. (when (= % 100.)
  144. ;; We're done, erase the line.
  145. (erase-current-line (current-error-port))
  146. (force-output (current-error-port)))
  147. ;; Return true to indicate that we should go on.
  148. #t)
  149. (define (make-default-fetch-options)
  150. "Return the default fetch options."
  151. (let ((auth-method (%make-auth-ssh-agent)))
  152. ;; The #:transfer-progress and #:proxy-url options appeared in Guile-Git
  153. ;; 0.4.0. Omit them when using an older version.
  154. (catch 'wrong-number-of-args
  155. (lambda ()
  156. (make-fetch-options auth-method
  157. ;; Guile-Git doesn't distinguish between these.
  158. #:proxy-url (or (getenv "http_proxy")
  159. (getenv "https_proxy"))
  160. #:transfer-progress
  161. (and (isatty? (current-error-port))
  162. show-progress)))
  163. (lambda args
  164. (make-fetch-options auth-method)))))
  165. (define (clone* url directory)
  166. "Clone git repository at URL into DIRECTORY. Upon failure,
  167. make sure no empty directory is left behind."
  168. (with-throw-handler #t
  169. (lambda ()
  170. (mkdir-p directory)
  171. (clone url directory
  172. (make-clone-options
  173. #:fetch-options (make-default-fetch-options))))
  174. (lambda _
  175. (false-if-exception (rmdir directory)))))
  176. (define (url+commit->name url sha1)
  177. "Return the string \"<REPO-NAME>-<SHA1:7>\" where REPO-NAME is the name of
  178. the git repository, extracted from URL and SHA1:7 the seven first digits
  179. of SHA1 string."
  180. (string-append
  181. (string-replace-substring
  182. (last (string-split url #\/)) ".git" "")
  183. "-" (string-take sha1 7)))
  184. (define (resolve-reference repository ref)
  185. "Resolve the branch, commit or tag specified by REF, and return the
  186. corresponding Git object."
  187. (let resolve ((ref ref))
  188. (match ref
  189. (('branch . branch)
  190. (let ((oid (reference-target
  191. (branch-lookup repository branch BRANCH-REMOTE))))
  192. (object-lookup repository oid)))
  193. (('symref . symref)
  194. (let ((oid (reference-name->oid repository symref)))
  195. (object-lookup repository oid)))
  196. (('commit . commit)
  197. (let ((len (string-length commit)))
  198. ;; 'object-lookup-prefix' appeared in Guile-Git in Mar. 2018, so we
  199. ;; can't be sure it's available. Furthermore, 'string->oid' used to
  200. ;; read out-of-bounds when passed a string shorter than 40 chars,
  201. ;; which is why we delay calls to it below.
  202. (if (< len 40)
  203. (object-lookup-prefix repository (string->oid commit) len)
  204. (object-lookup repository (string->oid commit)))))
  205. (('tag-or-commit . str)
  206. (if (or (> (string-length str) 40)
  207. (not (string-every char-set:hex-digit str)))
  208. (resolve `(tag . ,str)) ;definitely a tag
  209. (catch 'git-error
  210. (lambda ()
  211. (resolve `(tag . ,str)))
  212. (lambda _
  213. ;; There's no such tag, so it must be a commit ID.
  214. (resolve `(commit . ,str))))))
  215. (('tag . tag)
  216. (let ((oid (reference-name->oid repository
  217. (string-append "refs/tags/" tag))))
  218. ;; OID may point to a "tag" object, but it can also point directly
  219. ;; to a "commit" object, as surprising as it may seem. Return that
  220. ;; object, whatever that is.
  221. (object-lookup repository oid))))))
  222. (define (switch-to-ref repository ref)
  223. "Switch to REPOSITORY's branch, commit or tag specified by REF. Return the
  224. OID (roughly the commit hash) corresponding to REF."
  225. (define obj
  226. (resolve-reference repository ref))
  227. (reset repository obj RESET_HARD)
  228. (object-id obj))
  229. (define (call-with-repository directory proc)
  230. (let ((repository #f))
  231. (dynamic-wind
  232. (lambda ()
  233. (set! repository (repository-open directory)))
  234. (lambda ()
  235. (proc repository))
  236. (lambda ()
  237. (repository-close! repository)))))
  238. (define-syntax-rule (with-repository directory repository exp ...)
  239. "Open the repository at DIRECTORY and bind REPOSITORY to it within the
  240. dynamic extent of EXP."
  241. (call-with-repository directory
  242. (lambda (repository) exp ...)))
  243. (define (report-git-error error)
  244. "Report the given Guile-Git error."
  245. ;; Prior to Guile-Git commit b6b2760c2fd6dfaa5c0fedb43eeaff06166b3134,
  246. ;; errors would be represented by integers.
  247. (match error
  248. ((? integer? error) ;old Guile-Git
  249. (leave (G_ "Git error ~a~%") error))
  250. ((? git-error? error) ;new Guile-Git
  251. (leave (G_ "Git error: ~a~%") (git-error-message error)))))
  252. (define-syntax-rule (with-git-error-handling body ...)
  253. (catch 'git-error
  254. (lambda ()
  255. body ...)
  256. (lambda (key err)
  257. (report-git-error err))))
  258. (define* (update-submodules repository
  259. #:key (log-port (current-error-port))
  260. (fetch-options #f))
  261. "Update the submodules of REPOSITORY, a Git repository object."
  262. (for-each (lambda (name)
  263. (let ((submodule (submodule-lookup repository name)))
  264. (format log-port (G_ "updating submodule '~a'...~%")
  265. name)
  266. (submodule-update submodule
  267. #:fetch-options fetch-options)
  268. ;; Recurse in SUBMODULE.
  269. (let ((directory (string-append
  270. (repository-working-directory repository)
  271. "/" (submodule-path submodule))))
  272. (with-repository directory repository
  273. (update-submodules repository
  274. #:fetch-options fetch-options
  275. #:log-port log-port)))))
  276. (repository-submodules repository)))
  277. (define-syntax-rule (false-if-git-not-found exp)
  278. "Evaluate EXP, returning #false if a GIT_ENOTFOUND error is raised."
  279. (catch 'git-error
  280. (lambda ()
  281. exp)
  282. (lambda (key error . rest)
  283. (if (= GIT_ENOTFOUND (git-error-code error))
  284. #f
  285. (apply throw key error rest)))))
  286. (define (reference-available? repository ref)
  287. "Return true if REF, a reference such as '(commit . \"cabba9e\"), is
  288. definitely available in REPOSITORY, false otherwise."
  289. (match ref
  290. (('commit . commit)
  291. (let ((len (string-length commit))
  292. (oid (string->oid commit)))
  293. (false-if-git-not-found
  294. (->bool (if (< len 40)
  295. (object-lookup-prefix repository oid len OBJ-COMMIT)
  296. (commit-lookup repository oid))))))
  297. (_
  298. #f)))
  299. (define cached-checkout-expiration
  300. ;; Return the expiration time procedure for a cached checkout.
  301. ;; TODO: Honor $GUIX_GIT_CACHE_EXPIRATION.
  302. ;; Use the mtime rather than the atime to cope with file systems mounted
  303. ;; with 'noatime'.
  304. (file-expiration-time (* 90 24 3600) stat:mtime))
  305. (define %checkout-cache-cleanup-period
  306. ;; Period for the removal of expired cached checkouts.
  307. (* 5 24 3600))
  308. (define (delete-checkout directory)
  309. "Delete DIRECTORY recursively, in an atomic fashion."
  310. (let ((trashed (string-append directory ".trashed")))
  311. (rename-file directory trashed)
  312. (delete-file-recursively trashed)))
  313. (define* (update-cached-checkout url
  314. #:key
  315. (ref '())
  316. recursive?
  317. (check-out? #t)
  318. starting-commit
  319. (log-port (%make-void-port "w"))
  320. (cache-directory
  321. (url-cache-directory
  322. url (%repository-cache-directory)
  323. #:recursive? recursive?)))
  324. "Update the cached checkout of URL to REF in CACHE-DIRECTORY. Return three
  325. values: the cache directory name, and the SHA1 commit (a string) corresponding
  326. to REF, and the relation of the new commit relative to STARTING-COMMIT (if
  327. provided) as returned by 'commit-relation'.
  328. REF is pair whose key is [branch | commit | tag | tag-or-commit ] and value
  329. the associated data: [<branch name> | <sha1> | <tag name> | <string>].
  330. If REF is the empty list, the remote HEAD is used.
  331. When RECURSIVE? is true, check out submodules as well, if any.
  332. When CHECK-OUT? is true, reset the cached working tree to REF; otherwise leave
  333. it unchanged."
  334. (define (cache-entries directory)
  335. (filter-map (match-lambda
  336. ((or "." "..")
  337. #f)
  338. (file
  339. (string-append directory "/" file)))
  340. (or (scandir directory) '())))
  341. (define canonical-ref
  342. ;; We used to require callers to specify "origin/" for each branch, which
  343. ;; made little sense since the cache should be transparent to them. So
  344. ;; here we append "origin/" if it's missing and otherwise keep it.
  345. (match ref
  346. (() '(symref . "refs/remotes/origin/HEAD"))
  347. (('branch . branch)
  348. `(branch . ,(if (string-prefix? "origin/" branch)
  349. branch
  350. (string-append "origin/" branch))))
  351. (_ ref)))
  352. (with-libgit2
  353. (let* ((cache-exists? (openable-repository? cache-directory))
  354. (repository (if cache-exists?
  355. (repository-open cache-directory)
  356. (clone* url cache-directory))))
  357. ;; Only fetch remote if it has not been cloned just before.
  358. (when (and cache-exists?
  359. (not (reference-available? repository ref)))
  360. (remote-fetch (remote-lookup repository "origin")
  361. #:fetch-options (make-default-fetch-options)))
  362. (when recursive?
  363. (update-submodules repository #:log-port log-port
  364. #:fetch-options (make-default-fetch-options)))
  365. ;; Note: call 'commit-relation' from here because it's more efficient
  366. ;; than letting users re-open the checkout later on.
  367. (let* ((oid (if check-out?
  368. (switch-to-ref repository canonical-ref)
  369. (object-id
  370. (resolve-reference repository canonical-ref))))
  371. (new (and starting-commit
  372. (commit-lookup repository oid)))
  373. (old (and starting-commit
  374. (false-if-git-not-found
  375. (commit-lookup repository
  376. (string->oid starting-commit)))))
  377. (relation (and starting-commit
  378. (if old
  379. (commit-relation old new)
  380. 'unrelated))))
  381. ;; Reclaim file descriptors and memory mappings associated with
  382. ;; REPOSITORY as soon as possible.
  383. (repository-close! repository)
  384. ;; Update CACHE-DIRECTORY's mtime to so the cache logic sees it.
  385. (match (gettimeofday)
  386. ((seconds . microseconds)
  387. (let ((nanoseconds (* 1000 microseconds)))
  388. (utime cache-directory
  389. seconds seconds
  390. nanoseconds nanoseconds))))
  391. ;; When CACHE-DIRECTORY is a sub-directory of the default cache
  392. ;; directory, remove expired checkouts that are next to it.
  393. (let ((parent (dirname cache-directory)))
  394. (when (string=? parent (%repository-cache-directory))
  395. (maybe-remove-expired-cache-entries parent cache-entries
  396. #:entry-expiration
  397. cached-checkout-expiration
  398. #:delete-entry delete-checkout
  399. #:cleanup-period
  400. %checkout-cache-cleanup-period)))
  401. (values cache-directory (oid->string oid) relation)))))
  402. (define* (latest-repository-commit store url
  403. #:key
  404. recursive?
  405. (log-port (%make-void-port "w"))
  406. (cache-directory
  407. (%repository-cache-directory))
  408. (ref '()))
  409. "Return two values: the content of the git repository at URL copied into a
  410. store directory and the sha1 of the top level commit in this directory. The
  411. reference to be checkout, once the repository is fetched, is specified by REF.
  412. REF is pair whose key is [branch | commit | tag] and value the associated
  413. data, respectively [<branch name> | <sha1> | <tag name>]. If REF is the empty
  414. list, the remote HEAD is used.
  415. When RECURSIVE? is true, check out submodules as well, if any.
  416. Git repositories are kept in the cache directory specified by
  417. %repository-cache-directory parameter.
  418. Log progress and checkout info to LOG-PORT."
  419. (define (dot-git? file stat)
  420. (and (string=? (basename file) ".git")
  421. (or (eq? 'directory (stat:type stat))
  422. ;; Submodule checkouts end up with a '.git' regular file that
  423. ;; contains metadata about where their actual '.git' directory
  424. ;; lives.
  425. (and recursive?
  426. (eq? 'regular (stat:type stat))))))
  427. (format log-port "updating checkout of '~a'...~%" url)
  428. (let*-values
  429. (((checkout commit _)
  430. (update-cached-checkout url
  431. #:recursive? recursive?
  432. #:ref ref
  433. #:cache-directory
  434. (url-cache-directory url cache-directory
  435. #:recursive?
  436. recursive?)
  437. #:log-port log-port))
  438. ((name)
  439. (url+commit->name url commit)))
  440. (format log-port "retrieved commit ~a~%" commit)
  441. (values (add-to-store store name #t "sha256" checkout
  442. #:select? (negate dot-git?))
  443. commit)))
  444. (define (print-git-error port key args default-printer)
  445. (match args
  446. (((? git-error? error) . _)
  447. (format port (G_ "Git error: ~a~%")
  448. (git-error-message error)))))
  449. (set-exception-printer! 'git-error print-git-error)
  450. ;;;
  451. ;;; Commit difference.
  452. ;;;
  453. (define* (commit-closure commit #:optional (visited (setq)))
  454. "Return the closure of COMMIT as a set. Skip commits contained in VISITED,
  455. a set, and adjoin VISITED to the result."
  456. (let loop ((commits (list commit))
  457. (visited visited))
  458. (match commits
  459. (()
  460. visited)
  461. ((head . tail)
  462. (if (set-contains? visited head)
  463. (loop tail visited)
  464. (loop (append (commit-parents head) tail)
  465. (set-insert head visited)))))))
  466. (define* (commit-difference new old #:optional (excluded '()))
  467. "Return the list of commits between NEW and OLD, where OLD is assumed to be
  468. an ancestor of NEW. Exclude all the commits listed in EXCLUDED along with
  469. their ancestors.
  470. Essentially, this computes the set difference between the closure of NEW and
  471. that of OLD."
  472. (let loop ((commits (list new))
  473. (result '())
  474. (visited (fold commit-closure
  475. (setq)
  476. (cons old excluded))))
  477. (match commits
  478. (()
  479. (reverse result))
  480. ((head . tail)
  481. (if (set-contains? visited head)
  482. (loop tail result visited)
  483. (loop (append (commit-parents head) tail)
  484. (cons head result)
  485. (set-insert head visited)))))))
  486. (define (commit-relation old new)
  487. "Return a symbol denoting the relation between OLD and NEW, two commit
  488. objects: 'ancestor (meaning that OLD is an ancestor of NEW), 'descendant, or
  489. 'unrelated, or 'self (OLD and NEW are the same commit)."
  490. (if (eq? old new)
  491. 'self
  492. (let ((newest (commit-closure new)))
  493. (if (set-contains? newest old)
  494. 'ancestor
  495. (let* ((seen (list->setq (commit-parents new)))
  496. (oldest (commit-closure old seen)))
  497. (if (set-contains? oldest new)
  498. 'descendant
  499. 'unrelated))))))
  500. ;;;
  501. ;;; Checkouts.
  502. ;;;
  503. ;; Representation of the "latest" checkout of a branch or a specific commit.
  504. (define-record-type* <git-checkout>
  505. git-checkout make-git-checkout
  506. git-checkout?
  507. (url git-checkout-url)
  508. (branch git-checkout-branch (default #f))
  509. (commit git-checkout-commit (default #f)) ;#f | tag | commit
  510. (recursive? git-checkout-recursive? (default #f)))
  511. (define* (latest-repository-commit* url #:key ref recursive? log-port)
  512. ;; Monadic variant of 'latest-repository-commit'.
  513. (lambda (store)
  514. ;; The caller--e.g., (guix scripts build)--may not handle 'git-error' so
  515. ;; translate it into '&message' conditions that we know will be properly
  516. ;; handled.
  517. (catch 'git-error
  518. (lambda ()
  519. (values (latest-repository-commit store url
  520. #:ref ref
  521. #:recursive? recursive?
  522. #:log-port log-port)
  523. store))
  524. (lambda (key error . _)
  525. (raise (condition
  526. (&message
  527. (message
  528. (match ref
  529. (('commit . commit)
  530. (format #f (G_ "cannot fetch commit ~a from ~a: ~a")
  531. commit url (git-error-message error)))
  532. (('branch . branch)
  533. (format #f (G_ "cannot fetch branch '~a' from ~a: ~a")
  534. branch url (git-error-message error)))
  535. (_
  536. (format #f (G_ "Git failure while fetching ~a: ~a")
  537. url (git-error-message error))))))))))))
  538. (define-gexp-compiler (git-checkout-compiler (checkout <git-checkout>)
  539. system target)
  540. ;; "Compile" CHECKOUT by updating the local checkout and adding it to the
  541. ;; store.
  542. (match checkout
  543. (($ <git-checkout> url branch commit recursive?)
  544. (latest-repository-commit* url
  545. #:ref (cond (commit
  546. `(tag-or-commit . ,commit))
  547. (branch
  548. `(branch . ,branch))
  549. (else '()))
  550. #:recursive? recursive?
  551. #:log-port (current-error-port)))))
  552. ;; Local Variables:
  553. ;; eval: (put 'with-repository 'scheme-indent-function 2)
  554. ;; End: