Walk the FETCH_HEAD using a foreach loop.
1 auto repo = initRepo(_userRepo, OpenBare.yes); 2 scope(exit) rmdirRecurse(_userRepo); 3 4 string[] fetchHeadItems = [ 5 "23c3c6add8162693f85b3b41c9bf6550a71a57d3 branch 'master' of git://github.com/D-Programming-Language/dmd\n", 6 "aaf64112624abab1f6cc8f610223f6e12b525e09 branch 'master' of git://github.com/D-Programming-Language/dmd\n" 7 ]; 8 9 std.file.write(buildPath(repo.path, "FETCH_HEAD"), fetchHeadItems.join()); 10 11 size_t count; 12 foreach (refName, remoteURL, oid, isMerge; repo.walkFetchHead) 13 { 14 string line = fetchHeadItems[count++]; 15 string commitHex = line.split[0]; 16 17 assert(refName == "refs/heads/master"); 18 assert(remoteURL == "git://github.com/D-Programming-Language/dmd"); 19 assert(oid == GitOid(commitHex)); 20 } 21 22 // ensure we've iterated all itmes 23 assert(count == 2); 24 25 count = 0; 26 foreach (refName, remoteURL, oid, isMerge; repo.walkFetchHead) 27 { 28 string line = fetchHeadItems[count++]; 29 string commitHex = line.split[0]; 30 31 assert(refName == "refs/heads/master"); 32 assert(remoteURL == "git://github.com/D-Programming-Language/dmd"); 33 assert(oid == GitOid(commitHex)); 34 break; 35 } 36 37 // ensure 'break' works 38 assert(count == 1);
Walk the FETCH_HEAD file in a foreach loop.