From e0963a7cd45b1f154f74083a4d86a360adee0c96 Mon Sep 17 00:00:00 2001 From: Gary Verhaegen Date: Mon, 18 Mar 2024 19:17:52 +0100 Subject: [PATCH] [sync] fix canton pull (#18781) --- ci/cron/daily-compat.yml | 6 +++--- ci/refresh-canton.sh | 15 +++++++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/ci/cron/daily-compat.yml b/ci/cron/daily-compat.yml index 2742140b5a..ea185b6f50 100644 --- a/ci/cron/daily-compat.yml +++ b/ci/cron/daily-compat.yml @@ -184,16 +184,16 @@ jobs: git fetch git checkout origin/$(Build.SourceBranchName) - ci/refresh-canton.sh + version=$(ci/refresh-canton.sh) - branch="main-canton-update-$canton3_version" + branch="main-canton-update-$version" if git diff --exit-code origin/$(Build.SourceBranchName) -- canton build.sh >/dev/null; then echo "Already up-to-date with latest Canton source & snapshot." else if [ "main" = "$(Build.SourceBranchName)" ]; then git add build.sh canton - open_pr "$branch" "update canton to $canton3_version" "tell-slack: canton" "" "$(Build.SourceBranchName)" + open_pr "$branch" "update canton to $version" "tell-slack: canton" "" "$(Build.SourceBranchName)" az extension add --name azure-devops trap "az devops logout" EXIT echo "$(System.AccessToken)" | az devops login --org "https://dev.azure.com/digitalasset" diff --git a/ci/refresh-canton.sh b/ci/refresh-canton.sh index d24b90bdfe..4bfe7083d5 100755 --- a/ci/refresh-canton.sh +++ b/ci/refresh-canton.sh @@ -8,7 +8,7 @@ DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" cd "$DIR/.." if [ -z "${GITHUB_TOKEN:-}" ]; then - echo "This script requires GITHUB_TOKEN to be a valid GitHub token with read access to DACH-NY/canton." + echo "> This script requires GITHUB_TOKEN to be a valid GitHub token with read access to DACH-NY/canton." >&2 exit 1 fi @@ -20,9 +20,9 @@ CANTON_DIR=${1:-//unset} if [ "//unset" = "$CANTON_DIR" ]; then CANTON_DIR=$(realpath "$DIR/../.canton") - echo "Using '$CANTON_DIR' as '\$1' was not provided." >&2 + echo "> Using '$CANTON_DIR' as '\$1' was not provided." >&2 if ! [ -d "$CANTON_DIR" ]; then - echo "Cloning canton for the first time, this may take a while..." >&2 + echo "> Cloning canton for the first time, this may take a while..." >&2 git clone git@github.com:DACH-NY/canton.git "$CANTON_DIR" >$LOG 2>&1 fi ( @@ -33,7 +33,7 @@ if [ "//unset" = "$CANTON_DIR" ]; then fi if ! [ -d "$CANTON_DIR" ]; then - echo "CANTON_DIR '$CANTON_DIR' does not seem to exist." + echo "> CANTON_DIR '$CANTON_DIR' does not seem to exist." >&2 exit 1 fi @@ -53,4 +53,11 @@ for path in community daml-common-staging README.md; do done done +commit_sha_8=$(git -C "$CANTON_DIR" log -n1 --format=%h --abbrev=8 HEAD) +commit_date=$(git -C "$CANTON_DIR" log -n1 --format=%cd --date=format:%Y%m%d HEAD) +number_of_commits=$(git -C "$CANTON_DIR" rev-list --count HEAD) +is_modified=$(if ! git -C "$CANTON_DIR" diff-index --quiet HEAD; then echo "-dirty"; fi) + +echo $commit_date.$number_of_commits.v$commit_sha_8$is_modified + trap - EXIT