MCPcopy Create free account
hub / github.com/libgit2/pygit2 / create

Method create

pygit2/remotes.py:447–468  ·  view source on GitHub ↗

Create a new remote with the given name and url. Returns a object. If 'fetch' is provided, this fetch refspec will be used instead of the default.

(self, name: str, url: str, fetch: str | None = None)

Source from the content-addressed store, hash-verified

445 yield maybe_string(name)
446
447 def create(self, name: str, url: str, fetch: str | None = None) -> Remote:
448 """Create a new remote with the given name and url. Returns a <Remote>
449 object.
450
451 If 'fetch' is provided, this fetch refspec will be used instead of the
452 default.
453 """
454 cremote = ffi.new('git_remote **')
455
456 name_bytes = to_bytes(name)
457 url_bytes = to_bytes(url)
458 if fetch:
459 fetch_bytes = to_bytes(fetch)
460 err = C.git_remote_create_with_fetchspec(
461 cremote, self._repo._repo, name_bytes, url_bytes, fetch_bytes
462 )
463 else:
464 err = C.git_remote_create(cremote, self._repo._repo, name_bytes, url_bytes)
465
466 check_error(err)
467
468 return Remote(self._repo, cremote[0])
469
470 def create_anonymous(self, url: str) -> Remote:
471 """Create a new anonymous (in-memory only) remote with the given URL.

Callers

nothing calls this directly

Calls 3

to_bytesFunction · 0.85
check_errorFunction · 0.85
RemoteClass · 0.85

Tested by

no test coverage detected