This repo contains code to mirror other repos. It also contains the code that is getting mirrored.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

36 lines
752 B

  1. import re
  2. import sys
  3. import unittest
  4. # man git-check-ref-format
  5. reponameregex = re.compile(r'^(https://(?P<domain>github\.com)/(?P<slashpath>.*)\.git$)')
  6. def doconvert(i):
  7. mat = reponameregex.match(i)
  8. gd = mat.groupdict()
  9. p = gd['slashpath'].replace('/', '-')
  10. return '%s--%s' % (gd['domain'], p)
  11. if __name__ == '__main__':
  12. for i in sys.stdin:
  13. i = i.strip()
  14. if not i or i.startswith('#'):
  15. continue
  16. print(i, doconvert(i))
  17. class _TestCases(unittest.TestCase):
  18. def test_foo(self):
  19. data = [
  20. ('https://github.com/python/cpython.git', 'github.com--python-cpython'),
  21. ]
  22. for i in data:
  23. r = doconvert(i[0])
  24. self.assertEqual(r, i[1], msg='%s resulting in %s, should have been %s' % tuple(repr(x) for x in (i[0], r, i[1])))