Git Product home page Git Product logo

Comments (4)

seancorfield avatar seancorfield commented on July 25, 2024 2

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.

seancorfield avatar seancorfield commented on July 25, 2024

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.

rafaeldelboni avatar rafaeldelboni commented on July 25, 2024

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.

rafaeldelboni avatar rafaeldelboni commented on July 25, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.