| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent fc96980 commit b98f15e
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,11 +2,25 @@ | |||
| 2 | 2 | ||
| 3 | 3 | set -eu | |
| 4 | 4 | ||
| 5 | + fallback_repo_for_tags='https://github.com/gitpython-developers/GitPython.git' | ||
| 6 | + | ||
| 5 | 7 | ci() { | |
| 6 | 8 | # For now, check just these, as a false positive could lead to data loss. | |
| 7 | 9 | test -n "${TRAVIS-}" || test -n "${GITHUB_ACTIONS-}" | |
| 8 | 10 | } | |
| 9 | 11 | ||
| 12 | + no_version_tags() { | ||
| 13 | + test -z "$(git tag -l '[0-9]*' 'v[0-9]*')" | ||
| 14 | + } | ||
| 15 | + | ||
| 16 | + warn() { | ||
| 17 | + printf '%s\n' "$@" >&2 # Warn in step output. | ||
| 18 | + | ||
| 19 | + if test -n "${GITHUB_ACTIONS-}"; then | ||
| 20 | + printf '::warning ::%s\n' "$*" >&2 # Annotate workflow. | ||
| 21 | + fi | ||
| 22 | + } | ||
| 23 | + | ||
| 10 | 24 | if ! ci; then | |
| 11 | 25 | printf 'This operation will destroy locally modified files. Continue ? [N/y]: ' >&2 | |
| 12 | 26 | read -r answer | |
@@ -33,11 +47,27 @@ git reset --hard HEAD~1 | |||
| 33 | 47 | # Point the master branch where we started, so we test the correct code. | |
| 34 | 48 | git reset --hard __testing_point__ | |
| 35 | 49 | ||
| 36 | - # Do some setup that CI takes care of but that may not have been done locally. | ||
| 50 | + # The tests need submodules. (On CI, they would already have been checked out.) | ||
| 37 | 51 | if ! ci; then | |
| 38 | - # The tests need some version tags. Try to get them even in forks. | ||
| 52 | + git submodule update --init --recursive | ||
| 53 | + fi | ||
| 54 | + | ||
| 55 | + # The tests need some version tags. Try to get them even in forks. This fetch | ||
| 56 | + # gets other objects too, so for a consistent experience, always do it locally. | ||
| 57 | + if ! ci || no_version_tags; then | ||
| 39 | 58 | git fetch --all --tags | |
| 59 | + fi | ||
| 40 | 60 | ||
| 41 | - # The tests need submodules, including a submodule with a submodule. | ||
| 42 | - git submodule update --init --recursive | ||
| 61 | + # If we still have no version tags, try to get them from the original repo. | ||
| 62 | + if no_version_tags; then | ||
| 63 | + warn 'No local or remote version tags found. Trying fallback remote:' \ | ||
| 64 | + "$fallback_repo_for_tags" | ||
| 65 | + | ||
| 66 | + # git fetch supports * but not [], and --no-tags means no *other* tags, so... | ||
| 67 | + printf 'refs/tags/%d*:refs/tags/%d*\n' 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 | | ||
| 68 | + xargs git fetch --no-tags "$fallback_repo_for_tags" | ||
| 69 | + | ||
| 70 | + if no_version_tags; then | ||
| 71 | + warn 'No version tags found anywhere. Some tests will fail.' | ||
| 72 | + fi | ||
| 43 | 73 | fi | |
| Back | FazBrowse Home | New Git URL |
0 commit comments