From cbcb198dce951305c77ff4b265709fea957a4efe Mon Sep 17 00:00:00 2001 From: Guillaume de Rouville Date: Tue, 6 Jul 2021 11:49:47 +0200 Subject: [PATCH] git package - add keepGitDir option Signed-off-by: Guillaume de Rouville --- stdlib/git/git.cue | 12 +++++++++--- stdlib/git/tests/git.cue | 29 +++++++++++++++++++++-------- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/stdlib/git/git.cue b/stdlib/git/git.cue index 82d58b5e..ee852ee8 100644 --- a/stdlib/git/git.cue +++ b/stdlib/git/git.cue @@ -11,19 +11,25 @@ import ( #Repository: { // Git remote. // Example: `"https://github.com/dagger/dagger"` - remote: string @dagger(input) + remote: string & dagger.#Input // Git ref: can be a commit, tag or branch. // Example: "main" - ref: string @dagger(input) + ref: string & dagger.#Input // (optional) Subdirectory - subdir: string | *null @dagger(input) + subdir: *null | string & dagger.#Input + + // (optional) Keep .git directory + keepGitDir: *false | bool #up: [ op.#FetchGit & { "remote": remote "ref": ref + if (keepGitDir) { + keepGitDir: true + } }, if subdir != null { op.#Subdir & { diff --git a/stdlib/git/tests/git.cue b/stdlib/git/tests/git.cue index 59e65d47..f266223a 100644 --- a/stdlib/git/tests/git.cue +++ b/stdlib/git/tests/git.cue @@ -6,18 +6,19 @@ import ( "alpha.dagger.io/git" "alpha.dagger.io/alpine" "alpha.dagger.io/os" - "alpha.dagger.io/dagger/op" ) repo: git.#Repository & { - remote: "https://github.com/blocklayerhq/acme-clothing.git" - ref: "master" + remote: "https://github.com/blocklayerhq/acme-clothing.git" + ref: "master" + keepGitDir: true +} - #up: [ - op.#FetchGit & { - keepGitDir: true - }, - ] +repoSubDir: git.#Repository & { + remote: "https://github.com/dagger/examples.git" + ref: "main" + subdir: "todoapp" + keepGitDir: true } branch: git.#CurrentBranch & { @@ -40,6 +41,18 @@ TestRepository: os.#Container & { """ } +TestSubRepository: os.#Container & { + image: alpine.#Image & { + package: bash: "=5.1.0-r0" + package: git: true + } + mount: "/repo1": from: repoSubDir + dir: "/repo1" + command: """ + [ -d src ] + """ +} + TestCurrentBranch: os.#Container & { image: alpine.#Image & { package: bash: "=5.1.0-r0"