diff --git a/examples/remote-sources/README.md b/examples/remote-sources/README.md index f49dacf266..75c23e7147 100644 --- a/examples/remote-sources/README.md +++ b/examples/remote-sources/README.md @@ -70,12 +70,12 @@ project: name: remote-sources sources: - name: web-services - repositoryUrl: https://github.com/garden-io/garden-example-remote-sources-web-services.git#master + repositoryUrl: https://github.com/garden-io/garden-example-remote-sources-web-services.git#v0.1.0 - name: db-services - repositoryUrl: https://github.com/garden-io/garden-example-remote-sources-db-services.git#master + repositoryUrl: https://github.com/garden-io/garden-example-remote-sources-db-services.git#v0.1.0 ``` -> Remote repository URLs must contain a hash part that references a specific branch or tag, e.g. `https://github.com/org/repo.git/#v1.0`. +> Remote repository URLs must contain a hash part that references a specific branch or tag, e.g. `https://github.com/org/repo.git/#my-tag-or-branch`. The remote repositories used in this example all contain the tag `v0.1.0`. Read more about Git tagging [here](https://git-scm.com/book/en/v2/Git-Basics-Tagging). ### Configuring remote modules @@ -94,7 +94,7 @@ module: description: worker type: container name: jworker - repositoryUrl: https://github.com/garden-io/garden-example-remote-module-jworker.git#master + repositoryUrl: https://github.com/garden-io/garden-example-remote-module-jworker.git#v0.1.0 services: - name: javaworker dependencies: diff --git a/examples/remote-sources/garden.yml b/examples/remote-sources/garden.yml index 8bb675c24d..fa5842682d 100644 --- a/examples/remote-sources/garden.yml +++ b/examples/remote-sources/garden.yml @@ -2,6 +2,6 @@ project: name: remote-sources sources: - name: web-services - repositoryUrl: https://github.com/garden-io/garden-example-remote-sources-web-services.git#master + repositoryUrl: https://github.com/garden-io/garden-example-remote-sources-web-services.git#v0.1.0 - name: db-services - repositoryUrl: https://github.com/garden-io/garden-example-remote-sources-db-services.git#master + repositoryUrl: https://github.com/garden-io/garden-example-remote-sources-db-services.git#v0.1.0 diff --git a/examples/remote-sources/services/jworker/garden.yml b/examples/remote-sources/services/jworker/garden.yml index a88fdd1055..400e31537f 100644 --- a/examples/remote-sources/services/jworker/garden.yml +++ b/examples/remote-sources/services/jworker/garden.yml @@ -2,7 +2,7 @@ module: description: worker type: container name: jworker - repositoryUrl: https://github.com/garden-io/garden-example-remote-module-jworker.git#master + repositoryUrl: https://github.com/garden-io/garden-example-remote-module-jworker.git#v0.1.0 services: - name: javaworker dependencies: diff --git a/garden-service/src/vcs/git.ts b/garden-service/src/vcs/git.ts index 574ecf4fef..f39b585478 100644 --- a/garden-service/src/vcs/git.ts +++ b/garden-service/src/vcs/git.ts @@ -12,7 +12,7 @@ import { ensureDir, pathExists, stat } from "fs-extra" import Bluebird = require("bluebird") import { NEW_MODULE_VERSION, VcsHandler, RemoteSourceParams } from "./base" -import { ConfigurationError } from "../exceptions" +import { ConfigurationError, RuntimeError } from "../exceptions" export const helpers = { gitCli: (cwd: string): (cmd: string, args: string[]) => Promise => { @@ -105,7 +105,15 @@ export class GitHandler extends VcsHandler { const entry = logEntry.info({ section: name, msg: `Fetching from ${url}`, status: "active" }) const { repositoryUrl, hash } = parseGitUrl(url) - await git("clone", ["--depth=1", `--branch=${hash}`, repositoryUrl, absPath]) + try { + await git("clone", ["--depth=1", `--branch=${hash}`, repositoryUrl, absPath]) + } catch (err) { + entry.setError() + throw new RuntimeError(`Downloading remote ${sourceType} failed with error: \n\n${err}`, { + repositoryUrl: url, + message: err.message, + }) + } entry.setSuccess() } @@ -129,8 +137,16 @@ export class GitHandler extends VcsHandler { if (localCommitId !== remoteCommitId) { entry.setState(`Fetching from ${url}`) - await git("fetch", ["--depth=1", "origin", hash]) - await git("reset", ["--hard", `origin/${hash}`]) + try { + await git("fetch", ["--depth=1", "origin", hash]) + await git("reset", ["--hard", `origin/${hash}`]) + } catch (err) { + entry.setError() + throw new RuntimeError(`Updating remote ${sourceType} failed with error: \n\n${err}`, { + repositoryUrl: url, + message: err.message, + }) + } entry.setSuccess("Source updated") } else {