Git fork
at reftables-rust 110 lines 2.4 kB view raw
1#!/bin/sh 2 3test_description='git remote group handling' 4GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main 5export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME 6 7. ./test-lib.sh 8 9mark() { 10 echo "$1" >mark 11} 12 13update_repo() { 14 (cd $1 && 15 echo content >>file && 16 git add file && 17 git commit -F ../mark) 18} 19 20update_repos() { 21 update_repo one $1 && 22 update_repo two $1 23} 24 25repo_fetched() { 26 if test "$(git log -1 --pretty=format:%s $1 --)" = "$(cat mark)"; then 27 echo >&2 "repo was fetched: $1" 28 return 0 29 fi 30 echo >&2 "repo was not fetched: $1" 31 return 1 32} 33 34test_expect_success 'setup' ' 35 mkdir one && (cd one && git init) && 36 mkdir two && (cd two && git init) && 37 git remote add -m main one one && 38 git remote add -m main two two 39' 40 41test_expect_success 'no group updates all' ' 42 mark update-all && 43 update_repos && 44 git remote update && 45 repo_fetched one && 46 repo_fetched two 47' 48 49test_expect_success 'nonexistent group produces error' ' 50 mark nonexistent && 51 update_repos && 52 test_must_fail git remote update nonexistent && 53 ! repo_fetched one && 54 ! repo_fetched two 55' 56 57test_expect_success 'updating group updates all members (remote update)' ' 58 mark group-all && 59 update_repos && 60 git config --add remotes.all one && 61 git config --add remotes.all two && 62 git remote update all && 63 repo_fetched one && 64 repo_fetched two 65' 66 67test_expect_success 'updating group updates all members (fetch)' ' 68 mark fetch-group-all && 69 update_repos && 70 git fetch all && 71 repo_fetched one && 72 repo_fetched two 73' 74 75test_expect_success 'updating group does not update non-members (remote update)' ' 76 mark group-some && 77 update_repos && 78 git config --add remotes.some one && 79 git remote update some && 80 repo_fetched one && 81 ! repo_fetched two 82' 83 84test_expect_success 'updating group does not update non-members (fetch)' ' 85 mark fetch-group-some && 86 update_repos && 87 git config --add remotes.some one && 88 git remote update some && 89 repo_fetched one && 90 ! repo_fetched two 91' 92 93test_expect_success 'updating remote name updates that remote' ' 94 mark remote-name && 95 update_repos && 96 git remote update one && 97 repo_fetched one && 98 ! repo_fetched two 99' 100 101test_expect_success 'updating group in parallel with a duplicate remote does not fail (fetch)' ' 102 mark fetch-group-duplicate && 103 update_repo one && 104 git config --add remotes.duplicate one && 105 git config --add remotes.duplicate one && 106 git -c fetch.parallel=2 remote update duplicate && 107 repo_fetched one 108' 109 110test_done