diff --git a/go.mod b/go.mod index d585e910..0dcbd499 100644 --- a/go.mod +++ b/go.mod @@ -19,6 +19,6 @@ require ( k8s.io/client-go v0.21.4 k8s.io/code-generator v0.21.4 k8s.io/kube-openapi v0.0.0-20210305001622-591a79e4bda7 - knative.dev/hack v0.0.0-20211102174540-b284d49386cc - knative.dev/pkg v0.0.0-20211103135647-464034912f7e + knative.dev/hack v0.0.0-20211105231158-29f86c2653b5 + knative.dev/pkg v0.0.0-20211104101302-51b9e7f161b4 ) diff --git a/go.sum b/go.sum index 60e0b441..091f03d7 100644 --- a/go.sum +++ b/go.sum @@ -1130,11 +1130,11 @@ k8s.io/kube-openapi v0.0.0-20210305001622-591a79e4bda7 h1:vEx13qjvaZ4yfObSSXW7Br k8s.io/kube-openapi v0.0.0-20210305001622-591a79e4bda7/go.mod h1:wXW5VT87nVfh/iLV8FpR2uDvrFyomxbtb1KivDbvPTE= k8s.io/utils v0.0.0-20201110183641-67b214c5f920 h1:CbnUZsM497iRC5QMVkHwyl8s2tB3g7yaSHkYPkpgelw= k8s.io/utils v0.0.0-20201110183641-67b214c5f920/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= -knative.dev/hack v0.0.0-20211101195839-11d193bf617b/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI= -knative.dev/hack v0.0.0-20211102174540-b284d49386cc h1:eO3AtpzYua2uPO5LyQtse/i84B4isDyeQubNzIkTHEg= knative.dev/hack v0.0.0-20211102174540-b284d49386cc/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI= -knative.dev/pkg v0.0.0-20211103135647-464034912f7e h1:HEblpdzDnRVdJpclBVKTgShbL+gNuPIVbhQdn+sBdVg= -knative.dev/pkg v0.0.0-20211103135647-464034912f7e/go.mod h1:a+9AWOb0zOaBVU6xoPgTvEA7vfMnLjPnK4SX3ciSHKE= +knative.dev/hack v0.0.0-20211105231158-29f86c2653b5 h1:9scsqLnVcUh6wnMY0vYo8MGBy1NAkjpjoukyhhkChU4= +knative.dev/hack v0.0.0-20211105231158-29f86c2653b5/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI= +knative.dev/pkg v0.0.0-20211104101302-51b9e7f161b4 h1:X1CGp8wqBcIWfuz5uIH1yo011/SFPMPPP7Qe8KyRiyI= +knative.dev/pkg v0.0.0-20211104101302-51b9e7f161b4/go.mod h1:EKhRrRSAHrnJwQPfgUyrmHgLCam9xcRh79t+G3MJu4k= pgregory.net/rapid v0.3.3/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= diff --git a/vendor/knative.dev/hack/library.sh b/vendor/knative.dev/hack/library.sh index 0d52ad68..4af73bec 100644 --- a/vendor/knative.dev/hack/library.sh +++ b/vendor/knative.dev/hack/library.sh @@ -771,6 +771,7 @@ function current_branch() { # Get the branch name from Prow's env var, see https://github.com/kubernetes/test-infra/blob/master/prow/jobs.md. # Otherwise, try getting the current branch from git. (( IS_PROW )) && branch_name="${PULL_BASE_REF:-}" + [[ -z "${branch_name}" ]] && branch_name="${GITHUB_BASE_REF:-}" [[ -z "${branch_name}" ]] && branch_name="$(git rev-parse --abbrev-ref HEAD)" echo "${branch_name}" } @@ -835,30 +836,56 @@ function shellcheck_new_files() { fi } +# Note: if using Github checkout action please ensure you fetch all tags prior to calling +# this function +# +# ie. +# - uses: actions/checkout@v2 +# with: +# fetch-depth: 0 +# +# See: https://github.com/actions/checkout#fetch-all-history-for-all-tags-and-branches function latest_version() { local branch_name="$(current_branch)" - if [ "$branch_name" = "master" ] || [ "$branch_name" = "main" ]; then - # For main branch, simply use git tag without major version, this will work even - # if the release tag is not in the main + # Use the latest release for main + if [[ "$branch_name" == "main" ]] || [[ "$branch_name" == "master" ]]; then git tag -l "*$(git tag -l "*v[0-9]*" | cut -d '-' -f2 | sort -r --version-sort | head -n1)*" - else - ## Assumption here is we are on a release branch - local major_minor="${branch_name##release-}" - local major_version="$(major_version $major_minor)" - local minor_version="$(minor_version $major_minor)" - - # Hardcode the jump back from 1.0 - if [ "$major_version" = "1" ] && [ "$minor_version" == 0 ]; then - local tag='v0.26*' - else - # Adjust the minor down by one - local tag="*v$major_version.$(( minor_version - 1 ))*" - fi - - # Get the latest patch release for the major minor - git tag -l "${tag}*" | sort -r --version-sort | head -n1 + return fi + + # Ideally we shouldn't need to treat release branches differently but + # there are scenarios where git describe will return newer tags than + # the ones on the current branch + # + # ie. create a PR pulling commits from 0.24 into a release-0.23 branch + if [[ "$branch_name" == "release-"* ]]; then + # Infer major, minor version from the branch name + local tag="${branch_name##release-}" + else + # Nearest tag with the `knative-` prefix + local tag=$(git describe --abbrev=0 --match "knative-v[0-9]*") + + # Fallback to older tag scheme vX.Y.Z + [[ -z "${tag}" ]] && tag=$(git describe --abbrev=0 --match "v[0-9]*") + + # Drop the prefix + tag="${tag##knative-}" + fi + + local major_version="$(major_version ${tag})" + local minor_version="$(minor_version ${tag})" + + # Hardcode the jump back from 1.0 + if [ "$major_version" = "1" ] && [ "$minor_version" = "0" ]; then + local tag_filter='v0.26*' + else + # Adjust the minor down by one + local tag_filter="*v$major_version.$(( minor_version - 1 ))*" + fi + + # Get the latest patch release for the major minor + git tag -l "${tag_filter}" | sort -r --version-sort | head -n1 } # Initializations that depend on previous functions. diff --git a/vendor/modules.txt b/vendor/modules.txt index 2931e770..63e2b997 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -608,10 +608,10 @@ k8s.io/kube-openapi/pkg/util/sets k8s.io/utils/buffer k8s.io/utils/integer k8s.io/utils/trace -# knative.dev/hack v0.0.0-20211102174540-b284d49386cc +# knative.dev/hack v0.0.0-20211105231158-29f86c2653b5 ## explicit knative.dev/hack -# knative.dev/pkg v0.0.0-20211103135647-464034912f7e +# knative.dev/pkg v0.0.0-20211104101302-51b9e7f161b4 ## explicit knative.dev/pkg/apis knative.dev/pkg/apis/duck