From fe0e8d947c7bec7c274e96a3bba2e501ceee6599 Mon Sep 17 00:00:00 2001 From: yaokai13 Date: Mon, 21 Jun 2021 10:50:24 +0800 Subject: [PATCH] fix bug for bush to gitee in getdate.py --- core/getdate.py | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/core/getdate.py b/core/getdate.py index 173fdd0..bb6e3b9 100644 --- a/core/getdate.py +++ b/core/getdate.py @@ -169,21 +169,23 @@ class GETDate(object): """ push the latest obs_pkg_rpms to origin """ - for i in range(5): - push_cmd = "cd obs_pkg_rpms && git add * && \ - git commit -m 'update for package' && git push && cd -" - push_result = subprocess.getstatusoutput(push_cmd) - log.info(push_result) - if "nothing to commit" in push_result[1]: - log.info("SUCCESS:All the package date in <<%s>> \ - already be latest!!" % self.branch) - return - elif push_result[0] == 0: - log.info("SUCCESS:Push success for latest date to obs_pkg_rpms") - return - else: - log.debug("Try Push to obs_pkg_rpms: %s" % i) - raise SystemExit("Failed: Push to obs_pkg_rpms failed") + os.chdir("obs_pkg_rpms") + status_cmd = "git status -s" + commit_cmd = "git add -A && git commit -m 'update for package'" + if os.popen(status_cmd).read(): + if os.system(commit_cmd) == 0: + for i in range(5): + push_cmd = "git push -f" + push_result = subprocess.getstatusoutput(push_cmd) + log.info(push_result) + if push_result[0] == 0: + log.info("SUCCESS:Push success for latest date to obs_pkg_rpms") + return + else: + log.debug("Try Push to obs_pkg_rpms: %s" % i) + raise SystemExit("Failed: Push to obs_pkg_rpms failed") + else: + log.info("NO CHAGE,nothing to commit") def update_to_obs_pkg_rpms(self): """ -- Gitee