diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2020-09-28 19:12:00 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2022-01-25 14:46:34 +0530 |
commit | c36c78f3bcdb8a6cf9bd887e729ca6b758e93a6f (patch) | |
tree | 714ddccb3b895efeaddb4f148a104b9b9d053a54 | |
parent | 1b1b2860ee77d4d216629338280ef515e98f89a4 (diff) |
cerbero: Don't try to git commit if nothing to commit
git commit will fail if there's nothing to commit. This can happen if
all the commands in the extract step completed successfully, but the
step was marked as failed or was cancelled. In that case, the step
will be tried again and since all commands will be idempotent, there
won't be anything to commit.
Check whether we need to commit before trying to commit.
Part-of: <https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/784>
-rw-r--r-- | cerbero/utils/git.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/cerbero/utils/git.py b/cerbero/utils/git.py index 47757485..4b25c1e7 100644 --- a/cerbero/utils/git.py +++ b/cerbero/utils/git.py @@ -271,7 +271,12 @@ def init_directory(git_dir, logfile=None): ''' init(git_dir, logfile=logfile) shell.new_call([GIT, 'add', '--force', '-A', '.'], git_dir, logfile=logfile) - shell.new_call([GIT, 'commit', '-m', 'Initial commit'], git_dir, logfile=logfile) + # Check if we need to commit anything. This can happen when extract failed + # or was cancelled somehow last time but the source tree was setup + # correctly and git commit succeeded. + ret = shell.new_call([GIT, 'diff', '--quiet', 'HEAD'], git_dir, logfile=logfile, fail=False) + if ret > 0: + shell.new_call([GIT, 'commit', '-m', 'Initial commit'], git_dir, logfile=logfile) def apply_patch(patch, git_dir, logfile=None): |