Comments (4)
tools.build
has https://clojure.github.io/tools.build/clojure.tools.build.api.html#var-git-process so you don't need the private function. I'm a bit surprised you need any of that impl
stuff -- once you have resolved the SHA, using the public API I linked to in my deps.edn
file, you can use tools.deps
to resolve the dependency. There are definitely multiple ways to make this work.
from deps-new.
Currently, deps-new
does nothing for dependencies: it works with what is on the classpath already. To support what you're suggesting, it would need to be able to resolve dependencies itself, and build a new classpath based on that. In other words, it would need to duplicate some of the Clojure CLI itself -- which, as you observe, is what clj-new
does.
I certainly could add this, using tools.deps
and tools.gitlibs
-- see https://github.com/seancorfield/dot-clojure/blob/develop/deps.edn#L115-L121 for how to resolve a branch to a SHA (but I'd have to research how to figure out the default branch since a lot of repos do not have master
these days).
Part of why I created deps-new
was to provide a simpler template system, that just built on tools.build
and the existing CLI machinery.
Someone could build a wrapper for deps-new
that provided this functionality -- and if they submitted it as a PR to enhance deps-new
, I would consider it for review and possible inclusion...
from deps-new.
I was doing some experiments here, unfortunately the raw run-git
is private and I don't know if this solution works in all the cases, but I will post here in order to document:
(ns cc.delboni.gitlib-poc
(:require [clojure.string :as str]
[clojure.tools.gitlibs.impl :as impl])
(:gen-class))
(def run-git #'impl/run-git)
(defn git-rev-parse
[git-dir]
(let [{:keys [exit out]} (run-git "--git-dir" git-dir "rev-parse" "--abbrev-ref" "HEAD")]
(when (zero? exit)
(str/trimr out))))
(defn fetch-repository
[url]
(let [git-dir (impl/ensure-git-dir url)
rev-parse (git-rev-parse git-dir)
latest-hash (impl/git-rev-parse git-dir "HEAD")]
{:git-dir git-dir
:head-branch rev-parse
:latest-hash latest-hash}))
(fetch-repository "https://github.com/clojure/clojure-site.git")
(fetch-repository "https://github.com/rafaeldelboni/helix-scratch.git")
(fetch-repository "https://github.com/seancorfield/next-jdbc.git")
(fetch-repository "https://gitlab.com/aszenz/exosphere.git")
(fetch-repository "https://bitbucket.org/fumming/todo-clj.git")
Outputs:
; --------------------------------------------------------------------------------
; eval (current-form): (fetch-repository "https://github.com/clojure/clo...
; (err) Cloning: https://github.com/clojure/clojure-site.git
{:git-dir
"/Users/rafael.delboni/.gitlibs/_repos/https/github.com/clojure/clojure-site",
:head-branch "master",
:latest-hash "490e088af9d7de11ab3627c5ab566e9a8f714c25"}
; --------------------------------------------------------------------------------
; eval (current-form): (fetch-repository "https://github.com/rafaeldelbo...
; (err) Cloning: https://github.com/rafaeldelboni/helix-scratch.git
{:git-dir
"/Users/rafael.delboni/.gitlibs/_repos/https/github.com/rafaeldelboni/helix-scratch",
:head-branch "main",
:latest-hash "a8121c785c6e861795113ff8c96526cae6363964"}
; --------------------------------------------------------------------------------
; eval (current-form): (fetch-repository "https://github.com/seancorfiel...
; (err) Cloning: https://github.com/seancorfield/next-jdbc.git
{:git-dir
"/Users/rafael.delboni/.gitlibs/_repos/https/github.com/seancorfield/next-jdbc",
:head-branch "develop",
:latest-hash "a7833b1858ef908f69cf33b514b529ad216b297d"}
; --------------------------------------------------------------------------------
; eval (current-form): (fetch-repository "https://gitlab.com/aszenz/exos...
; (err) Cloning: https://gitlab.com/aszenz/exosphere.git
{:git-dir
"/Users/rafael.delboni/.gitlibs/_repos/https/gitlab.com/aszenz/exosphere",
:head-branch "master",
:latest-hash "a9d26e0c364f13d15e47e2a0f747a4e3b94f8d0c"}
; --------------------------------------------------------------------------------
; eval (current-form): (fetch-repository "https://bitbucket.org/fumming/...
; (err) Cloning: https://bitbucket.org/fumming/todo-clj.git
{:git-dir
"/Users/rafael.delboni/.gitlibs/_repos/https/bitbucket.org/fumming/todo-clj",
:head-branch "master",
:latest-hash "42b340686e09ec185d65c4340c0dcfb9f06e61ed"}
from deps-new.
I will close this issue for now, not super proud of my work, but this wrapper is working fine so far:
https://github.com/rafaeldelboni/deps-new-wrap
If you have some feedback to make it better I would love to hear.
Thanks a lot for your help here and in clojurians slack channel Sean, I really like your work and help to the community.
from deps-new.
Related Issues (20)
- scratch template does not use :name HOT 18
- Support loading template files through multiple deps HOT 3
- [Feature request] Add ability to use conditions in templates HOT 2
- how to build ci with aliases HOT 1
- add sr.ht and Codeberg as SCM domains HOT 6
- Consider not using .clj for extension of template source files HOT 3
- Consider supporting additional document formats like AsciiDoc? HOT 9
- Drop use of build-clj from templates HOT 1
- Update to non-alpha tools.deps HOT 1
- Consider moving pom.xml to template folder HOT 1
- [template] .tmpl files remain after creating a new project with template template HOT 3
- Consider publish to mvn also? HOT 5
- Add .portal/vs-code.edn to .gitignore
- When updating dependencies in deps.edn, the method for adjusting the dependency repository HOT 4
- Some of template seems too old to use HOT 3
- Running basic tests for a new app HOT 2
- Make deps-new more usable as a library HOT 1
- It should not be necessary to use -Sdeps to reference a third-party template HOT 3
- Release 0.7.1 has title 0.7.0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deps-new.