diff --git a/src/lay/lay/laySaltParsedURL.cc b/src/lay/lay/laySaltParsedURL.cc index 8df57de5f..11767b1b4 100644 --- a/src/lay/lay/laySaltParsedURL.cc +++ b/src/lay/lay/laySaltParsedURL.cc @@ -101,24 +101,22 @@ parse_git_url (tl::Extractor &ex, std::string &url, std::string &branch, std::st // SVN emulation auto parts = tl::split (subfolder, "/"); - if (parts.size () >= 1 && parts.back () == "trunk") { + if (parts.size () >= 1 && parts.front () == "trunk") { branch = "HEAD"; - parts.pop_back (); + parts.erase (parts.begin ()); subfolder = tl::join (parts, "/"); - } else if (parts.size () >= 2 && parts[parts.size () - 2] == "tags") { + } else if (parts.size () >= 2 && parts.front () == "tags") { - branch = "refs/tags/" + parts.back (); - parts.pop_back (); - parts.pop_back (); + branch = "refs/tags/" + parts[1]; + parts.erase (parts.begin (), parts.begin () + 2); subfolder = tl::join (parts, "/"); - } else if (parts.size () >= 2 && parts[parts.size () - 2] == "branches") { + } else if (parts.size () >= 2 && parts.front () == "branches") { - branch = "refs/heads/" + parts.back (); - parts.pop_back (); - parts.pop_back (); + branch = "refs/heads/" + parts[1]; + parts.erase (parts.begin (), parts.begin () + 2); subfolder = tl::join (parts, "/"); } diff --git a/src/lay/lay/laySaltParsedURL.h b/src/lay/lay/laySaltParsedURL.h index 770395a64..fd41bb42d 100644 --- a/src/lay/lay/laySaltParsedURL.h +++ b/src/lay/lay/laySaltParsedURL.h @@ -55,10 +55,10 @@ enum Protocol { * git+https://server.com/repo.git[v1.0] -> protocol=Git, url="https://server.com/repo.git", branch="v1.0", subfolder="" * git+https://server.com/repo.git/sub/folder[refs/tags/1.0] -> protocol=Git, url="https://server.com/repo.git", branch="refs/tags/1.0", subfolder="sub/folder" * git+https://server.com/repo.git/trunk -> protocol=Git, url="https://server.com/repo.git", branch="HEAD", subfolder="" - * git+https://server.com/repo.git/sub/folder/trunk -> protocol=Git, url="https://server.com/repo.git", branch="HEAD", subfolder="sub/folder" + * git+https://server.com/repo.git/trunk/sub/folder -> protocol=Git, url="https://server.com/repo.git", branch="HEAD", subfolder="sub/folder" * git+https://server.com/repo.git/branches/release -> protocol=Git, url="https://server.com/repo.git", branch="refs/heads/release", subfolder="" * git+https://server.com/repo.git/tags/1.9 -> protocol=Git, url="https://server.com/repo.git", branch="refs/tags/1.9", subfolder="" - * git+https://server.com/repo.git/sub/folder/tags/1.9 -> protocol=Git, url="https://server.com/repo.git", branch="refs/tags/1.9", subfolder="sub/folder" + * git+https://server.com/repo.git/tags/1.9/sub/folder -> protocol=Git, url="https://server.com/repo.git", branch="refs/tags/1.9", subfolder="sub/folder" */ class LAY_PUBLIC SaltParsedURL diff --git a/src/lay/unit_tests/laySaltParsedURLTests.cc b/src/lay/unit_tests/laySaltParsedURLTests.cc index 3b4985d88..96e22e5b6 100644 --- a/src/lay/unit_tests/laySaltParsedURLTests.cc +++ b/src/lay/unit_tests/laySaltParsedURLTests.cc @@ -97,7 +97,7 @@ TEST (15_GitSVNEmulationTrunk) TEST (16_GitSVNEmulationTrunkWithSubFolder) { - lay::SaltParsedURL purl ("git+https://server.com/repo.git/sub/folder/trunk"); + lay::SaltParsedURL purl ("git+https://server.com/repo.git/trunk/sub/folder"); EXPECT_EQ (purl.protocol () == lay::Git, true); EXPECT_EQ (purl.url (), "https://server.com/repo.git"); EXPECT_EQ (purl.branch (), "HEAD"); @@ -124,7 +124,7 @@ TEST (18_GitSVNEmulationTag) TEST (19_GitSVNEmulationTagWithSubFolder) { - lay::SaltParsedURL purl ("git+https://server.com/repo.git/sub/folder/tags/1.9"); + lay::SaltParsedURL purl ("git+https://server.com/repo.git/tags/1.9/sub/folder"); EXPECT_EQ (purl.protocol () == lay::Git, true); EXPECT_EQ (purl.url (), "https://server.com/repo.git"); EXPECT_EQ (purl.branch (), "refs/tags/1.9");