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

Method rename

pygit2/remotes.py:480–499  ·  view source on GitHub ↗

Rename a remote in the configuration. The refspecs in standard format will be renamed. Returns a list of fetch refspecs (list of strings) which were not in the standard format and thus could not be remapped.

(self, name: str, new_name: str)

Source from the content-addressed store, hash-verified

478 return Remote(self._repo, cremote[0])
479
480 def rename(self, name: str, new_name: str) -> list[str]:
481 """Rename a remote in the configuration. The refspecs in standard
482 format will be renamed.
483
484 Returns a list of fetch refspecs (list of strings) which were not in
485 the standard format and thus could not be remapped.
486 """
487
488 if not name:
489 raise ValueError('Current remote name must be a non-empty string')
490
491 if not new_name:
492 raise ValueError('New remote name must be a non-empty string')
493
494 problems = ffi.new('git_strarray *')
495 err = C.git_remote_rename(
496 problems, self._repo._repo, to_bytes(name), to_bytes(new_name)
497 )
498 check_error(err)
499 return strarray_to_strings(problems)
500
501 def delete(self, name: str) -> None:
502 """Remove a remote from the configuration

Callers 1

RefdbBackend_renameFunction · 0.45

Calls 3

to_bytesFunction · 0.85
check_errorFunction · 0.85
strarray_to_stringsFunction · 0.85

Tested by

no test coverage detected