Commit db58954c authored by Dirk Pranke's avatar Dirk Pranke Committed by Commit Bot

Use the same git-cache bucket for authenticated and unauthenticated repos.

We should only be maintaining one cache bundle per repo, but it turns
out that we've had two in the past due to GoB supporting two different
paths to the repo, and users were getting stale bundles as a result.

This CL fixes things so that we should only get a single bundle per
repo.

Bug: 935084
Change-Id: I0d6713280a2abbc20e35ff87e7be115870dd5140
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1566431Reviewed-by: 's avatarAndrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Dirk Pranke <dpranke@chromium.org>
parent bd29f6f7
......@@ -264,6 +264,10 @@ class Mirror(object):
norm_url = parsed.netloc + parsed.path
if norm_url.endswith('.git'):
norm_url = norm_url[:-len('.git')]
# Use the same dir for authenticated URLs and unauthenticated URLs.
norm_url = norm_url.replace('googlesource.com/a/', 'googlesource.com/')
return norm_url.replace('-', '--').replace('/', '-').lower()
@staticmethod
......
......@@ -166,6 +166,18 @@ class GitCacheDirTest(unittest.TestCase):
os.environ[name] = val
class MirrorTest(unittest.TestCase):
def test_same_cache_for_authenticated_and_unauthenticated_urls(self):
# GoB can fetch a repo via two different URLs; if the url contains '/a/'
# it forces authenticated access instead of allowing anonymous access,
# even in the case where a repo is public. We want this in order to make
# sure bots are authenticated and get the right quotas. However, we
# only want to maintain a single cache for the repo.
self.assertEqual(git_cache.Mirror.UrlToCacheDir(
'https://chromium.googlesource.com/a/chromium/src.git'),
'chromium.googlesource.com-chromium-src')
if __name__ == '__main__':
sys.exit(coverage_utils.covered_main((
os.path.join(DEPOT_TOOLS_ROOT, 'git_cache.py')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment