diff --git a/python/git-init/README.md b/python/git-init/README.md index 7c08e313..919ff014 100644 --- a/python/git-init/README.md +++ b/python/git-init/README.md @@ -38,19 +38,20 @@ ssh-keygen -t ed25519 -C "Test TC Git Init SSH Keypair" export HTTP_PASSWORD=pat export SSH_PASSWORD=sshpw export SSH_REPO="git@gitlab.eclipse.org:username/my.repository.git" + export BRANCH=maintenance_1_1_x # HTTPS Public -docker run --rm theiacloud/theia-cloud-git-init:local "$HTTP_PUBLIC" "/tmp/my-repo" +docker run --rm theiacloud/theia-cloud-git-init:local "$HTTP_PUBLIC" "/tmp/my-repo" "$BRANCH" # HTTPS Private -docker run --env GIT_PROMPT1=$HTTP_USERNAME --env GIT_PROMPT2=$HTTP_PASSWORD --rm theiacloud/theia-cloud-git-init:local "$HTTP_PRIVATE" "/tmp/my-repo" +docker run --env GIT_PROMPT1=$HTTP_USERNAME --env GIT_PROMPT2=$HTTP_PASSWORD --rm theiacloud/theia-cloud-git-init:local "$HTTP_PRIVATE" "/tmp/my-repo" "$BRANCH" # HTTPS Private with Username -docker run --env GIT_PROMPT1=$HTTP_PASSWORD --rm theiacloud/theia-cloud-git-init:local "$HTTP_PRIVATE_WITH_USERNAME" "/tmp/my-repo" +docker run --env GIT_PROMPT1=$HTTP_PASSWORD --rm theiacloud/theia-cloud-git-init:local "$HTTP_PRIVATE_WITH_USERNAME" "/tmp/my-repo" "$BRANCH" # HTTPS Private with Username and Password -docker run --rm theiacloud/theia-cloud-git-init:local "$HTTP_PRIVATE_WITH_USERNAME_AND_PASSWORD" "/tmp/my-repo" +docker run --rm theiacloud/theia-cloud-git-init:local "$HTTP_PRIVATE_WITH_USERNAME_AND_PASSWORD" "/tmp/my-repo" "$BRANCH" # SSH -docker run --env GIT_PROMPT1=$SSH_PASSWORD -v ~/tmp/ssh/:/etc/theia-cloud-ssh --rm theiacloud/theia-cloud-git-init:local "$SSH_REPO" "/tmp/my-repo" +docker run --env GIT_PROMPT1=$SSH_PASSWORD -v ~/tmp/ssh/:/etc/theia-cloud-ssh --rm theiacloud/theia-cloud-git-init:local "$SSH_REPO" "/tmp/my-repo" "$BRANCH" ``` diff --git a/python/git-init/git-init.py b/python/git-init/git-init.py index d11d3de2..448fb1a9 100755 --- a/python/git-init/git-init.py +++ b/python/git-init/git-init.py @@ -58,6 +58,7 @@ def getHostname(repository): parser = argparse.ArgumentParser() parser.add_argument("repository", help="The repository URL", type=str) parser.add_argument("directory", help="The directory to clone into", type=str) +parser.add_argument("checkout", help="The branch/commit id/tag to checkout", type=str) args = parser.parse_args() # Set up git credential helper @@ -83,3 +84,11 @@ def getHostname(repository): if debugLogging: runProcess(["ls", "-al", args.directory]) + +# Checkout +code = runProcess(["git", "-C", args.directory, "checkout", args.checkout]) +if code != 0: + exit(code) + +if debugLogging: + runProcess(["git", "-C", args.directory, "status"])