MCPcopy Index your code
hub / github.com/gitless-vcs/gitless / RemoteCollection

Class RemoteCollection

gitless/core.py:407–445  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

405
406
407class RemoteCollection(object):
408
409 def __init__(self, git_remote_collection, gl_repo):
410 self.git_remote_collection = git_remote_collection
411 self.gl_repo = gl_repo
412
413 def __len__(self):
414 return len(self.git_remote_collection)
415
416 def __iter__(self):
417 return (Remote(r, self.gl_repo) for r in self.git_remote_collection)
418
419 def __getitem__(self, name):
420 return Remote(self.git_remote_collection.__getitem__(name), self.gl_repo)
421
422 def __contains__(self, name):
423 try:
424 self.git_remote_collection.__getitem__(name)
425 return True
426 except KeyError:
427 return False
428
429 def create(self, name, url):
430 if '/' in name:
431 raise ValueError(
432 'Invalid remote name {0}: remotes can\'t have \'/\''.format(name))
433 if not url.strip():
434 raise ValueError('Invalid url {0}'.format(url))
435
436 # Check that the given url corresponds to a git repo
437 try:
438 git('ls-remote', '--heads', url)
439 except ErrorReturnCode as e:
440 raise ValueError(stderr(e))
441
442 self.git_remote_collection.create(name, url)
443
444 def delete(self, name):
445 self.git_remote_collection.delete(name)
446
447
448class Remote(object):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected