aedi: remove most of git operations

ability to checkout a commit and implicit pull of remote changes were infinite source of errors
only initial clone of source code repository remains
This commit is contained in:
alexey.lysiuk 2021-04-10 14:35:12 +03:00
parent cac1d5cf8c
commit 539d67838f
2 changed files with 6 additions and 39 deletions

View file

@ -37,8 +37,6 @@ class Builder(object):
state = self._state = BuildState()
state.xcode = arguments.xcode
state.checkout_commit = arguments.checkout_commit
state.skip_checkout = arguments.skip_checkout
state.verbose = arguments.verbose
self._platforms = []
@ -291,12 +289,6 @@ class Builder(object):
group.add_argument('--target', choices=self._targets.keys(), help='target to build')
group.add_argument('--source', metavar='path', help='path to target\'s source code')
group = parser.add_mutually_exclusive_group()
group.add_argument('--checkout-commit', metavar='commit',
help='source code commit or tag to checkout')
group.add_argument('--skip-checkout', action='store_true',
help='avoid any operations with source code')
group = parser.add_argument_group()
group.add_argument('--xcode', action='store_true', help='generate Xcode project instead of build')
group.add_argument('--source-path', metavar='path',

View file

@ -44,9 +44,6 @@ class BuildState:
self.output_path = None
self.install_path = None
self.checkout_commit = None
self.skip_checkout = False
self.platform = None
self.xcode = False
self.verbose = False
@ -70,37 +67,15 @@ class BuildState:
def cxx_compiler(self) -> str:
return self.platform.cxx_compiler if self.platform else ''
def checkout_git(self, url: str, branch: str = 'master'):
def checkout_git(self, url: str, branch: str = None):
if os.path.exists(self.source):
if self.skip_checkout:
return
return
args = ('git', 'fetch', '--all', '--tags')
subprocess.run(args, cwd=self.source, check=True)
else:
assert not self.skip_checkout
args = ('git', 'clone', '--recurse-submodules', url, self.source)
subprocess.run(args, cwd=self.root_path, check=True)
args = ('git', 'clone', '--recurse-submodules', url, self.source)
subprocess.run(args, cwd=self.root_path, check=True)
if self.checkout_commit:
checkout_args = (self.checkout_commit,)
need_pull = False
else:
args = ('git', 'show-ref', '--quiet', 'refs/heads/' + branch)
branch_exists = 0 == subprocess.run(args, cwd=self.source).returncode
if branch_exists:
checkout_args = (branch,)
else:
checkout_args = ('-b', branch, 'origin/' + branch)
need_pull = True
args = ('git', 'checkout') + checkout_args
subprocess.run(args, cwd=self.source, check=True)
if need_pull:
args = ('git', 'pull')
if branch:
args = ('git', 'checkout', '-b', branch, 'origin/' + branch)
subprocess.run(args, cwd=self.source, check=True)
def download_source(self, url: str, checksum: str):