diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2014-07-04 17:17:23 +0200 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2014-07-04 18:00:20 +0200 |
commit | f5287fa6c39762072e30140329c41e9f304d7c04 (patch) | |
tree | d207cbde4ff25dacc34c76cfffd704a029b51785 /tests | |
parent | 9ed104a8fa9fc28bb29a0ff53c68094696e13aea (diff) | |
download | libgit2-f5287fa6c39762072e30140329c41e9f304d7c04.tar.gz |
refspec: support asterisks in the middle of a pattern
We used to assume a refspec would only have an asterisk in the middle of
their respective pattern. This has not been a valid assumption for some
time now with git.
Instead of assuming where the asterisk is going to be, change the logic
to treat each pattern as having two halves with a replacement bit in the
middle, where the asterisk is.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/network/refspecs.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/network/refspecs.c b/tests/network/refspecs.c index 676a1fa99..aa9b36e58 100644 --- a/tests/network/refspecs.c +++ b/tests/network/refspecs.c @@ -84,4 +84,27 @@ void test_network_refspecs__parsing(void) assert_refspec(GIT_DIRECTION_FETCH, "master", true); assert_refspec(GIT_DIRECTION_PUSH, "master", true); + + assert_refspec(GIT_DIRECTION_FETCH, "refs/pull/*/head:refs/remotes/origin/pr/*", true); +} + +void assert_transform(const char *refspec, const char *name, const char *result) +{ + git_refspec spec; + git_buf buf = GIT_BUF_INIT; + + git_refspec__parse(&spec, refspec, true); + cl_git_pass(git_refspec_transform(&buf, &spec, name)); + cl_assert_equal_s(result, buf.ptr); + + git_buf_free(&buf); + git_refspec__free(&spec); +} + +void test_network_refspecs__transform_mid_star(void) +{ + assert_transform("refs/pull/*/head:refs/remotes/origin/pr/*", "refs/pull/23/head", "refs/remotes/origin/pr/23"); + assert_transform("refs/heads/*:refs/remotes/origin/*", "refs/heads/master", "refs/remotes/origin/master"); + assert_transform("refs/heads/*:refs/heads/*", "refs/heads/master", "refs/heads/master"); + assert_transform("refs/*:refs/*", "refs/heads/master", "refs/heads/master"); } |