[projects/git-slug: 161/170] Warn when reinitializing existing .git directory

glen glen at pld-linux.org
Mon Sep 21 21:52:20 CEST 2015


commit 61005aac2d95489c54dc67039fd89124eb366350
Author: Kacper Kornet <draenog at pld-linux.org>
Date:   Fri Jan 18 15:21:17 2013 +0000

    Warn when reinitializing existing .git directory
    
    Previously only message from git: "Reinitialized existing Git repository
    in ..." warned that developer initialized new package in directory
    with already existing git repository. It tended to be overlooked which
    resulted in wrong pushes. This change makes the warning more prominent
    and sends it to stderr.

 git_slug/gitrepo.py | 3 +++
 1 file changed, 3 insertions(+)
---
diff --git a/git_slug/gitrepo.py b/git_slug/gitrepo.py
index 80e84a3..5234deb 100644
--- a/git_slug/gitrepo.py
+++ b/git_slug/gitrepo.py
@@ -3,6 +3,7 @@ from .gitconst import EMPTYSHA1, REMOTE_NAME, REFFILE
 import os
 from subprocess import PIPE
 import subprocess
+import sys
 
 class GitRepoError(Exception):
     pass
@@ -71,6 +72,8 @@ class GitRepo:
             raise GitRepoError(self.gdir)
 
     def init(self, remotepull, remotepush = None, remotename=REMOTE_NAME):
+        if os.path.isdir(self.gdir):
+            print("WARNING: Directory {} already existed".format(self.gdir), file=sys.stderr)
         self.init_gitdir()
         self.commandio(['remote', 'add', remotename, remotepull])
         if remotepush is not None:
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/git-slug.git/commitdiff/4ed64f73960519a2f4fd04c42950b2c96ae795c5



More information about the pld-cvs-commit mailing list