Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capture subshell output for OiCS #5553

Conversation

modular-magician
Copy link
Collaborator

I'd tested feeding variables in & error cases, but not actually the output. Editing them inside the subshell doesn't make it's way back to the parent. Capture the output from the subshell.

I get the output Diffs: TF OiCS: [Diff](https://github.com/modular-magician/docs-examples/compare/auto-pr-3050-old..auto-pr-3050) from the test script below:

set -e

PR_NUMBER=3050
NEW_BRANCH=auto-pr-$PR_NUMBER
OLD_BRANCH=auto-pr-$PR_NUMBER-old
TFOICS_SCRATCH_PATH=https://modular-magician:$GITHUB_TOKEN@github.com/modular-magician/docs-examples
TFOICS_LOCAL_PATH=$PWD/../tfoics

set +e
DIFFS="Diffs: "
VAR=$(bash -e <<TRY
    # TF OICS
    mkdir -p $TFOICS_LOCAL_PATH
    git clone -b $NEW_BRANCH $TFOICS_SCRATCH_PATH $TFOICS_LOCAL_PATH
    pushd $TFOICS_LOCAL_PATH > /dev/null
    git fetch origin $OLD_BRANCH
    if ! git diff --exit-code --quiet origin/$NEW_BRANCH origin/$OLD_BRANCH; then
        echo "TF OiCS: [Diff](https://github.com/modular-magician/docs-examples/compare/$OLD_BRANCH..$NEW_BRANCH)"
    fi
    popd > /dev/null
TRY
)
if [ $? -ne 0 ]; then
  echo caught exception
else
DIFFS="$DIFFS $VAR"
fi
set -e
echo $DIFFS

Release Note Template for Downstream PRs (will be copied)


Derived from GoogleCloudPlatform/magic-modules#3054

* Capture subshell output

* Make git diff silent

* Silence pushd, popd

Signed-off-by: Modular Magician <magic-modules@google.com>
@ghost ghost added the size/xs label Jan 31, 2020
@modular-magician modular-magician merged commit 87e1e91 into hashicorp:master Jan 31, 2020
@ghost
Copy link

ghost commented Mar 28, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant