Jeff King | 27845e9 | 2009-04-06 16:18:23 -0400 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='git remote group handling' |
| 4 | . ./test-lib.sh |
| 5 | |
| 6 | mark() { |
| 7 | echo "$1" >mark |
| 8 | } |
| 9 | |
| 10 | update_repo() { |
| 11 | (cd $1 && |
| 12 | echo content >>file && |
| 13 | git add file && |
| 14 | git commit -F ../mark) |
| 15 | } |
| 16 | |
| 17 | update_repos() { |
| 18 | update_repo one $1 && |
| 19 | update_repo two $1 |
| 20 | } |
| 21 | |
| 22 | repo_fetched() { |
Elia Pinto | e15243c | 2015-12-23 14:45:54 +0100 | [diff] [blame] | 23 | if test "$(git log -1 --pretty=format:%s $1 --)" = "$(cat mark)"; then |
Jeff King | 27845e9 | 2009-04-06 16:18:23 -0400 | [diff] [blame] | 24 | echo >&2 "repo was fetched: $1" |
| 25 | return 0 |
| 26 | fi |
| 27 | echo >&2 "repo was not fetched: $1" |
| 28 | return 1 |
| 29 | } |
| 30 | |
| 31 | test_expect_success 'setup' ' |
| 32 | mkdir one && (cd one && git init) && |
| 33 | mkdir two && (cd two && git init) && |
| 34 | git remote add -m master one one && |
| 35 | git remote add -m master two two |
| 36 | ' |
| 37 | |
| 38 | test_expect_success 'no group updates all' ' |
| 39 | mark update-all && |
| 40 | update_repos && |
| 41 | git remote update && |
| 42 | repo_fetched one && |
| 43 | repo_fetched two |
| 44 | ' |
| 45 | |
Dmitry Ivankov | 7be8b3b | 2011-06-16 19:42:48 +0600 | [diff] [blame] | 46 | test_expect_success 'nonexistent group produces error' ' |
| 47 | mark nonexistent && |
Jeff King | 27845e9 | 2009-04-06 16:18:23 -0400 | [diff] [blame] | 48 | update_repos && |
Dmitry Ivankov | 7be8b3b | 2011-06-16 19:42:48 +0600 | [diff] [blame] | 49 | test_must_fail git remote update nonexistent && |
Jeff King | 27845e9 | 2009-04-06 16:18:23 -0400 | [diff] [blame] | 50 | ! repo_fetched one && |
| 51 | ! repo_fetched two |
| 52 | ' |
| 53 | |
Björn Gustavsson | 9c4a036 | 2009-11-09 21:09:56 +0100 | [diff] [blame] | 54 | test_expect_success 'updating group updates all members (remote update)' ' |
Jeff King | 27845e9 | 2009-04-06 16:18:23 -0400 | [diff] [blame] | 55 | mark group-all && |
| 56 | update_repos && |
| 57 | git config --add remotes.all one && |
| 58 | git config --add remotes.all two && |
| 59 | git remote update all && |
| 60 | repo_fetched one && |
| 61 | repo_fetched two |
| 62 | ' |
| 63 | |
Björn Gustavsson | 9c4a036 | 2009-11-09 21:09:56 +0100 | [diff] [blame] | 64 | test_expect_success 'updating group updates all members (fetch)' ' |
| 65 | mark fetch-group-all && |
| 66 | update_repos && |
| 67 | git fetch all && |
| 68 | repo_fetched one && |
| 69 | repo_fetched two |
| 70 | ' |
| 71 | |
| 72 | test_expect_success 'updating group does not update non-members (remote update)' ' |
Jeff King | 27845e9 | 2009-04-06 16:18:23 -0400 | [diff] [blame] | 73 | mark group-some && |
| 74 | update_repos && |
| 75 | git config --add remotes.some one && |
| 76 | git remote update some && |
| 77 | repo_fetched one && |
| 78 | ! repo_fetched two |
| 79 | ' |
| 80 | |
Björn Gustavsson | 9c4a036 | 2009-11-09 21:09:56 +0100 | [diff] [blame] | 81 | test_expect_success 'updating group does not update non-members (fetch)' ' |
| 82 | mark fetch-group-some && |
| 83 | update_repos && |
| 84 | git config --add remotes.some one && |
| 85 | git remote update some && |
| 86 | repo_fetched one && |
| 87 | ! repo_fetched two |
| 88 | ' |
| 89 | |
Jeff King | 27845e9 | 2009-04-06 16:18:23 -0400 | [diff] [blame] | 90 | test_expect_success 'updating remote name updates that remote' ' |
| 91 | mark remote-name && |
| 92 | update_repos && |
| 93 | git remote update one && |
| 94 | repo_fetched one && |
| 95 | ! repo_fetched two |
| 96 | ' |
| 97 | |
| 98 | test_done |