Added: functions to remove a git remote

This commit is contained in:
Hanzhang Zeng (Roger) 2019-03-27 14:36:21 -07:00
Родитель 594f590468
Коммит cd1c3b4d45
2 изменённых файлов: 12 добавлений и 0 удалений

Просмотреть файл

@ -57,6 +57,13 @@ def git_add_remote(remote_name, remote_url):
except CalledProcessError:
raise GitOperationException(message=" ".join(command))
def git_remove_remote(remote_name):
command = ["git", "remote", "remove", remote_name]
try:
check_call(command, stdout=DEVNULL, stderr=STDOUT)
except CalledProcessError:
raise GitOperationException(message=" ".join(command))
def git_stage_all():
command = ["git", "add", "--all"]
try:

Просмотреть файл

@ -13,6 +13,7 @@ from . import models
from .local_git_utils import (
git_init,
git_add_remote,
git_remove_remote,
git_stage_all,
git_commit,
git_push,
@ -59,6 +60,10 @@ class RepositoryManager(BaseManager):
remote_name = construct_git_remote_name(self._organization_name, self._project_name, repository_name, remote_prefix)
return does_git_remote_exist(remote_name)
def remove_git_remote(self, repository_name, remote_prefix):
remote_name = construct_git_remote_name(self._organization_name, self._project_name, repository_name, remote_prefix)
git_remove_remote(remote_name)
def get_azure_devops_repository_branches(self, repository_name):
try:
result = self._git_client.get_branches(repository_name, self._project_name)