Skip to content

Commit

Permalink
Allow custom branch name in config (#3)
Browse files Browse the repository at this point in the history
* Allow custom branch name in config

Co-authored-by: Alix Fumoleau <afumoleau@betomorrow.com>
Co-authored-by: spouzols <spouzols@betomorrow.com>
  • Loading branch information
3 people authored Apr 30, 2021
1 parent 653ed02 commit 0a1c807
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ environment-file=something-else.json
# Remote repository, optional
# Used for load-remote to retrieve files to load into Postman cloud
remote-repository=git@somehost.com:repo/project.git

# Remote repository branch
# Required to use the remote repository
remote-repository-branch=main
```

## Commands
Expand Down
14 changes: 12 additions & 2 deletions pms
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ PROJECT_CONFIG_COLLECTION_NAME=collection-name
PROJECT_CONFIG_ENVIRONMENT_FILE=environment-file
PROJECT_CONFIG_ENVIRONMENT_NAME=environment-name
PROJECT_CONFIG_REMOTE_REPOSITORY=remote-repository
PROJECT_CONFIG_REMOTE_REPOSITORY_BRANCH=remote-repository-branch

configReadItem() {
local default_value=${3:-""}
Expand Down Expand Up @@ -84,10 +85,10 @@ loadEnvironment() {
}

remoteGitArchive() {
echo "Retrieving from remote repository $REMOTE_REPOSITORY"
echo "Retrieving from remote repository $REMOTE_REPOSITORY (branch $REMOTE_REPOSITORY_BRANCH)"
local paths=("$@")
if [ ${#paths[@]} -gt 0 ]; then
git archive --remote="$REMOTE_REPOSITORY" master "${paths[@]}" | tar -x
git archive --remote="$REMOTE_REPOSITORY" "$REMOTE_REPOSITORY_BRANCH" "${paths[@]}" | tar -x
fi
}

Expand Down Expand Up @@ -115,6 +116,11 @@ loadRemote() {
exit 2
fi

if [ -z "$REMOTE_REPOSITORY_BRANCH" ]; then
echo "No '${PROJECT_CONFIG_REMOTE_REPOSITORY_BRANCH}' configuration set."
exit 2
fi

local paths=()
if [ "${COLLECTION_NAME}" ]; then
paths+=("${COLLECTION_FILE}")
Expand Down Expand Up @@ -160,6 +166,7 @@ readProjectConfig() {
ENVIRONMENT_FILE="$(projectConfigGet "${PROJECT_CONFIG_ENVIRONMENT_FILE}" "${PROJECT_NAME}.postman_environment.json")"
ENVIRONMENT_NAME="$(projectConfigGet "${PROJECT_CONFIG_ENVIRONMENT_NAME}")"
REMOTE_REPOSITORY="$(projectConfigGet "${PROJECT_CONFIG_REMOTE_REPOSITORY}")"
REMOTE_REPOSITORY_BRANCH="$(projectConfigGet "${PROJECT_CONFIG_REMOTE_REPOSITORY_BRANCH}")"
}

initProjectProperty() {
Expand Down Expand Up @@ -195,6 +202,9 @@ init() {
initProjectProperty "${PROJECT_CONFIG_ENVIRONMENT_FILE}" "Environment file name, leave empty to use default file name" "Environment file name: "
fi
initProjectProperty "${PROJECT_CONFIG_REMOTE_REPOSITORY}" "Enter remote git repository, optional" "Repository: "
if [ -n "${REPLY}" ]; then
initProjectProperty "${PROJECT_CONFIG_REMOTE_REPOSITORY_BRANCH}" "Enter remote git repository branch" "Branch name: "
fi
fi
echo "All set."
}
Expand Down

0 comments on commit 0a1c807

Please sign in to comment.