handling base revision not found
using master instead
This commit is contained in:
parent
bf98f92a3d
commit
9f3db2cc48
1 changed files with 7 additions and 2 deletions
|
@ -21,7 +21,7 @@ import sys
|
||||||
from typing import List, Optional, Tuple
|
from typing import List, Optional, Tuple
|
||||||
|
|
||||||
from phabricator import Phabricator
|
from phabricator import Phabricator
|
||||||
from git import Repo
|
from git import Repo, GitCommandError
|
||||||
|
|
||||||
class ApplyPatch:
|
class ApplyPatch:
|
||||||
"""Apply a diff from Phabricator on local working copy.
|
"""Apply a diff from Phabricator on local working copy.
|
||||||
|
@ -76,7 +76,12 @@ class ApplyPatch:
|
||||||
try:
|
try:
|
||||||
revision_id, dependencies, base_revision = self._get_dependencies()
|
revision_id, dependencies, base_revision = self._get_dependencies()
|
||||||
print('Checking out {}...'.format(base_revision))
|
print('Checking out {}...'.format(base_revision))
|
||||||
self.repo.git.checkout(base_revision)
|
try:
|
||||||
|
self.repo.git.checkout(base_revision)
|
||||||
|
except GitCommandError:
|
||||||
|
print('ERROR checking out revision {}. It`s not in the '
|
||||||
|
'repository. Using master instead.'.format(base_revision))
|
||||||
|
self.repo.git.checkout('master')
|
||||||
print('Revision is {}'.format(self.repo.head.commit.hexsha))
|
print('Revision is {}'.format(self.repo.head.commit.hexsha))
|
||||||
print('git reset, git cleanup...')
|
print('git reset, git cleanup...')
|
||||||
self.repo.git.reset('--hard')
|
self.repo.git.reset('--hard')
|
||||||
|
|
Loading…
Reference in a new issue