From 539d67838f427e3eed03549c24a40fbe4b713133 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 10 Apr 2021 14:35:12 +0300 Subject: [PATCH] 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 --- aedi/builder.py | 8 -------- aedi/state.py | 37 ++++++------------------------------- 2 files changed, 6 insertions(+), 39 deletions(-) diff --git a/aedi/builder.py b/aedi/builder.py index 056dcbb1..63af2fe6 100644 --- a/aedi/builder.py +++ b/aedi/builder.py @@ -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', diff --git a/aedi/state.py b/aedi/state.py index e8ff04b9..c7649ff8 100644 --- a/aedi/state.py +++ b/aedi/state.py @@ -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):