def answer.clone

ezx@1.11.0.0 · src/lock/run.bend:211

import ezx@1.11.0.0/src/lock/run.bend as Run
import Base
import snap@1.4.0.0/main.bend as R
import ezx@1.11.0.0/src/share/say.bend as Say
import ezx@1.11.0.0/src/share/spin.bend as Spin
import ezx@1.11.0.0/src/lock/world.bend as W

211# a git package whose tree is not under BEND_LIB: a shallow clone at the rev
212# the ledger pins, the way `ez add` and `ez fetch` clone, from the source the
213# question names, which the planner anchored at the project root. Nothing is
214# laid here; the plan lays the tree once it has checked it.
215def answer.clone(+lib: String, +hash: String, +url: String, +rev: String, +entry: String) -> IO(W.Answer):
216  +work = lib ++ "/.work-" ++ hash
217  do IO<W.Answer>:
218    _rm : String <- R.exec(["rm", "-rf", work])
219    _mk : String <- R.exec(["mkdir", "-p", work])
220    +s : Say.Spin <- Spin.hold(Say.dep.git(Say.label(hash, entry), url))
221    a : W.Answer <- clone.run(work, "init", ["git", "init", "-q", work], _u =>
222      clone.run(work, "fetch", ["git", "-C", work, "fetch", "-q", "--depth", "1", url, rev], _v =>
223        clone.run(work, "checkout", ["git", "-C", work, "checkout", "-q", rev], _w =>
224          clone.weigh(work, url, rev, entry))))
225    Spin.done(s)
226    return a

Uses (16)

Used by (1)