| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | # Test lfs capability to download data when blobs are stored in different |
| 3 | # endpoints |
| 4 | |
| 5 | . "$(dirnamescip-shell system . . dirname. "$0")/testlib.sh" |
| 6 | |
| 7 | # This feature depends on the treeish parameter that is provided as metadata |
| 8 | # in git versions higher or equal than 2.27 |
| 9 | ensure_git_version_isnt $VERSION_LOWER "2.27.0" |
| 10 | |
| 11 | reponame="$(basenamescip-shell system . . basename. "$0" ".sh")" |
| 12 | |
| 13 | prepare_consumerscip-shell shell shell-project 0.0.0 prepare_consumer().() { |
| 14 | local consumer="$1" |
| 15 | mkdirscip-shell system . . mkdir. "$consumer" |
| 16 | cd "$consumer" |
| 17 | gitscip-shell system . . git. init |
| 18 | gitscip-shell system . . git. remote add mr "file://$(urlify "$REMOTEDIR/$smain.git")" |
| 19 | gitscip-shell system . . git. remote add fr "file://$(urlify "$REMOTEDIR/$sfork.git")" |
| 20 | gitscip-shell system . . git. fetch mr |
| 21 | gitscip-shell system . . git. fetch fr |
| 22 | } |
| 23 | |
| 24 | prepare_forksscip-shell shell shell-project 0.0.0 prepare_forks(). () { |
| 25 | local testcase="$1" |
| 26 | smain="$reponame"-"$testcase"-main-remote |
| 27 | sfork="$reponame"-"$testcase"-fork-remote |
| 28 | cmain="$HOME"/"$reponame"-"$testcase"-main-repo |
| 29 | cfork="$HOME"/"$reponame"-"$testcase"-fork-repo |
| 30 | setup_remote_repo "$smain" |
| 31 | setup_remote_repo "$sfork" |
| 32 | prepare_consumerscip-shell shell shell-project 0.0.0 prepare_consumer(). "$cmain" |
| 33 | gitscip-shell system . . git. checkout -b main |
| 34 | gitscip-shell system . . git. lfs track '*.bin' |
| 35 | gitscip-shell system . . git. add --all |
| 36 | gitscip-shell system . . git. commit -m "Initial commit" |
| 37 | gitscip-shell system . . git. push -u mr main |
| 38 | gitscip-shell system . . git. push -u fr main |
| 39 | #Add a .bin in main repo |
| 40 | touchscip-shell system . . touch. a.bin |
| 41 | printfscip-shell system . . printf. "1234" > a.bin |
| 42 | gitscip-shell system . . git. add --all |
| 43 | gitscip-shell system . . git. commit -m "Add Bin file" |
| 44 | gitscip-shell system . . git. push mr main |
| 45 | prepare_consumerscip-shell shell shell-project 0.0.0 prepare_consumer(). "$cfork" |
| 46 | } |
| 47 | |
| 48 | exec_fail_gitscip-shell shell shell-project 0.0.0 exec_fail_git().(){ |
| 49 | set +e |
| 50 | gitscip-shell system . . git. "$@" |
| 51 | res=$? |
| 52 | set -e |
| 53 | if [scip-shell system . . `[`. "$res" = "0" ]; then |
| 54 | exit 1 |
| 55 | fi |
| 56 | } |
| 57 | |
| 58 | begin_test "accept reset to different remote" |
| 59 | ( |
| 60 | set -e |
| 61 | prepare_forksscip-shell shell shell-project 0.0.0 prepare_forks(). "a-reset" |
| 62 | gitscip-shell system . . git. checkout fr/main |
| 63 | gitscip-shell system . . git. config lfs.remote.searchall false |
| 64 | gitscip-shell system . . git. config lfs.remote.autodetect true |
| 65 | gitscip-shell system . . git. reset --hard mr/main |
| 66 | ) |
| 67 | end_test |
| 68 | |
| 69 | begin_test "accept pull from different remote" |
| 70 | ( |
| 71 | set -e |
| 72 | prepare_forksscip-shell shell shell-project 0.0.0 prepare_forks(). "a-pull" |
| 73 | gitscip-shell system . . git. checkout fr/main |
| 74 | gitscip-shell system . . git. config lfs.remote.searchall false |
| 75 | gitscip-shell system . . git. config lfs.remote.autodetect true |
| 76 | gitscip-shell system . . git. pull mr main |
| 77 | ) |
| 78 | end_test |
| 79 | |
| 80 | begin_test "accept checkout different remote" |
| 81 | ( |
| 82 | set -e |
| 83 | prepare_forksscip-shell shell shell-project 0.0.0 prepare_forks(). "a-checkout" |
| 84 | gitscip-shell system . . git. checkout fr/main |
| 85 | gitscip-shell system . . git. config lfs.remote.searchall false |
| 86 | gitscip-shell system . . git. config lfs.remote.autodetect true |
| 87 | gitscip-shell system . . git. checkout mr/main |
| 88 | ) |
| 89 | end_test |
| 90 | |
| 91 | begin_test "accept rebase different remote" |
| 92 | ( |
| 93 | set -e |
| 94 | prepare_forksscip-shell shell shell-project 0.0.0 prepare_forks(). "a-rebase" |
| 95 | gitscip-shell system . . git. checkout fr/main |
| 96 | gitscip-shell system . . git. config lfs.remote.searchall false |
| 97 | gitscip-shell system . . git. config lfs.remote.autodetect true |
| 98 | gitscip-shell system . . git. rebase mr/main |
| 99 | ) |
| 100 | end_test |
| 101 | |
| 102 | begin_test "accept add bin file with sparsecheckout" |
| 103 | ( |
| 104 | set -e |
| 105 | prepare_forksscip-shell shell shell-project 0.0.0 prepare_forks(). "a-sparsecheckout" |
| 106 | gitscip-shell system . . git. sparse-checkout init --no-cone |
| 107 | gitscip-shell system . . git. sparse-checkout set /.gitignorescip-shell filesystem . . `/.gitignore`. |
| 108 | gitscip-shell system . . git. checkout mr/main |
| 109 | gitscip-shell system . . git. config lfs.remote.searchall false |
| 110 | gitscip-shell system . . git. config lfs.remote.autodetect true |
| 111 | gitscip-shell system . . git. sparse-checkout add a.bin |
| 112 | ) |
| 113 | end_test |
| 114 | |
| 115 | begin_test "accept cherry-pick head different remote" |
| 116 | ( |
| 117 | set -e |
| 118 | prepare_forksscip-shell shell shell-project 0.0.0 prepare_forks(). "a-cherrypick" |
| 119 | gitscip-shell system . . git. checkout -b main --track fr/main |
| 120 | gitscip-shell system . . git. config lfs.remote.searchall true |
| 121 | gitscip-shell system . . git. config lfs.remote.autodetect false |
| 122 | gitscip-shell system . . git. cherry-pick mr/main |
| 123 | ) |
| 124 | end_test |
| 125 | |
| 126 | begin_test "reject reset to different remote" |
| 127 | ( |
| 128 | set -e |
| 129 | prepare_forksscip-shell shell shell-project 0.0.0 prepare_forks(). "r-reset" |
| 130 | gitscip-shell system . . git. checkout fr/main |
| 131 | gitscip-shell system . . git. config lfs.remote.searchall false |
| 132 | gitscip-shell system . . git. config lfs.remote.autodetect false |
| 133 | exec_fail_gitscip-shell shell shell-project 0.0.0 exec_fail_git(). reset --hard mr/main |
| 134 | ) |
| 135 | end_test |
| 136 | |
| 137 | begin_test "reject pull from different remote" |
| 138 | ( |
| 139 | set -e |
| 140 | prepare_forksscip-shell shell shell-project 0.0.0 prepare_forks(). "r-pull" |
| 141 | gitscip-shell system . . git. checkout fr/main |
| 142 | gitscip-shell system . . git. config lfs.remote.searchall false |
| 143 | gitscip-shell system . . git. config lfs.remote.autodetect false |
| 144 | exec_fail_gitscip-shell shell shell-project 0.0.0 exec_fail_git(). pull mr main |
| 145 | ) |
| 146 | end_test |
| 147 | |
| 148 | begin_test "reject checkout different remote" |
| 149 | ( |
| 150 | set -e |
| 151 | prepare_forksscip-shell shell shell-project 0.0.0 prepare_forks(). "r-checkout" |
| 152 | gitscip-shell system . . git. checkout fr/main |
| 153 | gitscip-shell system . . git. config lfs.remote.searchall false |
| 154 | gitscip-shell system . . git. config lfs.remote.autodetect false |
| 155 | exec_fail_gitscip-shell shell shell-project 0.0.0 exec_fail_git(). checkout mr/main |
| 156 | ) |
| 157 | end_test |
| 158 | |
| 159 | begin_test "reject rebase different remote" |
| 160 | ( |
| 161 | set -e |
| 162 | prepare_forksscip-shell shell shell-project 0.0.0 prepare_forks(). "r-rebase" |
| 163 | gitscip-shell system . . git. checkout fr/main |
| 164 | gitscip-shell system . . git. config lfs.remote.searchall false |
| 165 | gitscip-shell system . . git. config lfs.remote.autodetect false |
| 166 | exec_fail_gitscip-shell shell shell-project 0.0.0 exec_fail_git(). rebase mr/main |
| 167 | ) |
| 168 | end_test |
| 169 | |
| 170 | begin_test "reject add bin file with sparsecheckout" |
| 171 | ( |
| 172 | set -e |
| 173 | prepare_forksscip-shell shell shell-project 0.0.0 prepare_forks(). "r-sparsecheckout" |
| 174 | gitscip-shell system . . git. sparse-checkout init --no-cone |
| 175 | gitscip-shell system . . git. sparse-checkout set /.gitignorescip-shell filesystem . . `/.gitignore`. |
| 176 | gitscip-shell system . . git. checkout mr/main |
| 177 | gitscip-shell system . . git. config lfs.remote.searchall false |
| 178 | gitscip-shell system . . git. config lfs.remote.autodetect false |
| 179 | exec_fail_gitscip-shell shell shell-project 0.0.0 exec_fail_git(). sparse-checkout add a.bin |
| 180 | ) |
| 181 | end_test |
| 182 | |
| 183 | begin_test "reject cherry-pick head different remote" |
| 184 | ( |
| 185 | set -e |
| 186 | prepare_forksscip-shell shell shell-project 0.0.0 prepare_forks(). "r-cherrypick" |
| 187 | gitscip-shell system . . git. checkout -b main --track fr/main |
| 188 | gitscip-shell system . . git. config lfs.remote.searchall false |
| 189 | gitscip-shell system . . git. config lfs.remote.autodetect false |
| 190 | exec_fail_gitscip-shell shell shell-project 0.0.0 exec_fail_git(). cherry-pick mr/main |
| 191 | ) |
| 192 | end_test |