[damned-lies] Prevent crash when branch dir is nonexistent
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Prevent crash when branch dir is nonexistent
- Date: Wed, 10 Aug 2016 07:29:26 +0000 (UTC)
commit f66156ef4846064c88ec996cbdea1c7c9cea1369
Author: Claude Paroz <claude 2xlibre net>
Date: Wed Aug 10 09:28:55 2016 +0200
Prevent crash when branch dir is nonexistent
stats/models.py | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/stats/models.py b/stats/models.py
index ed8082b..d84f2c9 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -248,14 +248,14 @@ class Branch(models.Model):
if os.access(self.co_path(), os.W_OK):
shutil.rmtree(self.co_path())
elif self.module.vcs_type == 'git':
- if self.is_head():
- if os.access(self.co_path(), os.W_OK):
- shutil.rmtree(self.co_path())
- else:
- wd = self.co_path()
- with ModuleLock(self.module):
- utils.run_shell_command(['git', 'checkout', 'master'], cwd=wd)
- utils.run_shell_command(['git', 'branch', '-D', self.name], cwd=wd)
+ wdir = self.co_path()
+ if os.access(wdir, os.W_OK):
+ if self.is_head():
+ shutil.rmtree(wdir)
+ else:
+ with ModuleLock(self.module):
+ utils.run_shell_command(['git', 'checkout', 'master'], cwd=wd)
+ utils.run_shell_command(['git', 'branch', '-D', self.name], cwd=wd)
#To be implemented for hg/bzr
# Remove the pot/po generated files
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]