From 7986cd61a5bf6045432cb14415f4002b5acd9d55 Mon Sep 17 00:00:00 2001 From: Qixiang Wan Date: Oct 18 2016 14:52:12 +0000 Subject: Commit -c should clean up after itself. If we run fedpkg commit with -c (generate the commit message from the %changelog), it should remove the generated temporary files behind itself. Fixes #16 Original patch from: Matěj Cepl Updated by: Qixiang Wan Signed-off-by: Qixiang Wan --- diff --git a/pyrpkg/cli.py b/pyrpkg/cli.py index 19743d9..1a263e2 100755 --- a/pyrpkg/cli.py +++ b/pyrpkg/cli.py @@ -1037,22 +1037,20 @@ see API KEY section of copr-cli(1) man page. try: self.cmd.commit(self.args.message, self.args.file, self.args.files, self.args.signoff) - except Exception: - if self.args.tag: - self.log.error('Could not commit, will not tag!') - if self.args.push: - self.log.error('Could not commit, will not push!') - raise - - try: if self.args.tag: tagname = self.cmd.nvr self.cmd.add_tag(tagname, True, self.args.message, self.args.file) except Exception: + if self.args.tag: + self.log.error('Could not commit, will not tag!') if self.args.push: - self.log.error('Could not tag, will not push!') + self.log.error('Could not commit, will not push!') raise + finally: + if self.args.clog and os.path.isfile(self.args.file): + os.remove(self.args.file) + del self.args.file if self.args.push: self.push()