From be4e0cc44d603220f1e2028c70d156fd9cac63ae Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Thu, 15 Dec 2022 13:34:45 +0100 Subject: [PATCH] Use old-style checkout for shortened refs Related: https://pagure.io/koji/issue/3629 --- koji/daemon.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/koji/daemon.py b/koji/daemon.py index 41ac10c5..fe712036 100644 --- a/koji/daemon.py +++ b/koji/daemon.py @@ -521,6 +521,7 @@ class SCM(object): sourcedir = '%s/%s' % (scmdir, self.module) update_checkout_cmds = None + update_recovery_cmd = None update_checkout_dir = None env = None @@ -587,6 +588,7 @@ class SCM(object): ['git', 'fetch', 'origin', '%s:KOJI_FETCH_HEAD' % rev], ['git', 'reset', '--hard', 'KOJI_FETCH_HEAD'] ] + update_recovery_cmd = ['git', 'reset', '--hard', self.revision] update_checkout_dir = sourcedir # self.module may be empty, in which case the specfile should be in the top-level @@ -625,6 +627,7 @@ class SCM(object): ['git', 'fetch', 'origin', '%s:KOJI_FETCH_HEAD' % rev], ['git', 'reset', '--hard', 'KOJI_FETCH_HEAD'] ] + update_recovery_cmd = ['git', 'reset', '--hard', self.revision] update_checkout_dir = sourcedir # self.module may be empty, in which case the specfile should be in the top-level @@ -667,8 +670,12 @@ class SCM(object): chdir=update_checkout_dir, fatal=True) _run(['git', 'config', 'core.safecrlf', 'true'], chdir=update_checkout_dir, fatal=True) - for cmd in update_checkout_cmds: - _run(cmd, chdir=update_checkout_dir, fatal=True) + try: + for cmd in update_checkout_cmds: + _run(cmd, chdir=update_checkout_dir, fatal=True) + except Exception: + # use old-style checkout, e.g. for shortened refs + _run(update_recovery_cmd, chdir=update_checkout_dir, fatal=True) if self.use_common and not globals().get('KOJIKAMID'): _run(common_checkout_cmd, chdir=scmdir, fatal=True)