Skip to content

Commit

Permalink
Update gitdiff-msteams.sh
Browse files Browse the repository at this point in the history
Updated with button that links to internal github
  • Loading branch information
mopi3456 authored Dec 4, 2024
1 parent e4aa929 commit 6a0dd6b
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions extra/gitdiff-msteams.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
# Add webhook to your MS Teams channel and set the next variable to the full url

weburl="https://contoso.webhook.office.com/webhookb2/etc etc etc"
NEWLINE=$'\n'
GITURL="https://github.example.com/My-org/oxidized/commit/"

# Max size before shortening
MAXSIZE=20000
# When shortening - how many lines to show
SHORTLINES=30

postdata()
{
Expand Down Expand Up @@ -83,8 +88,8 @@ postdata()
"actions": [
{
"type": "Action.OpenUrl",
"title": "Klik her for visning",
"url": "https://internalgithub/org/oxidized/commit/${OX_REPO_COMMITREF}"
"title": "Click to see diff in github",
"url": "${GITURL}${OX_REPO_COMMITREF}"
}
]
}
Expand All @@ -97,11 +102,12 @@ EOF
}

COMMIT=$(git --bare --git-dir="${OX_REPO_NAME}" show --pretty='' --no-color "${OX_REPO_COMMITREF}" | jq --raw-input --slurp --compact-output)
URL=""

size=$(postdata | wc -c)
if [ "$size" -gt "15000" ]; then
COMMIT=$(git --bare --git-dir="${OX_REPO_NAME}" show --pretty='' --no-color "${OX_REPO_COMMITREF}" | head -n 20)
COMMIT+="$NEWLINE...$NEWLINE Shortened because of length"
if [ "$size" -gt "$MAXSIZE" ]; then
COMMIT=$(git --bare --git-dir="${OX_REPO_NAME}" show --pretty='' --no-color "${OX_REPO_COMMITREF}" | head -n $SHORTLINES)
COMMIT+="$NEWLINE...$NEWLINE Shortened because of length, see full diff by clicking below button"
COMMIT=$(echo "${COMMIT}" | jq --raw-input --slurp --compact-output )
fi

Expand Down

0 comments on commit 6a0dd6b

Please sign in to comment.