]> git.pld-linux.org Git - packages/rpm-build-tools.git/blobdiff - check-unused-files.py
unset GIT_EDITOR together with other GIT_* vars
[packages/rpm-build-tools.git] / check-unused-files.py
index ef7dc5a1f3b516a22740a82fb49c077ae252b781..4ecc6a95816a7a062ca0d185f2e62166d44d2fd3 100755 (executable)
@@ -38,30 +38,29 @@ for l in out.split('\n'):
 obsolete = []
 
 # files to exclude
-exclude = ['log.*', '.#*', '*~', '*.orig', '*.sw?']
+exclude = ['log.*', '.#*', '*~', '*.orig', '*.sw?', '.bigfiles', 'sources']
 
-# read .cvsignore, distfiles files are filled there
-if os.path.isfile('%s/.cvsignore' % dir):
-    f = open('%s/.cvsignore' % dir , 'r')
+# read .gitignore, distfiles files are filled there
+if os.path.isfile('%s/.gitignore' % dir):
+    f = open('%s/.gitignore' % dir , 'r')
     for l in f.readlines():
         exclude.append(l.rstrip())
 
-def cvs_entries(file):
-    f = open('%s/CVS/Entries' % dir , 'r')
-    files = []
-    for l in f.readlines():
-        if l[0] != '/':
-            continue
-        parts = l.split('/')
-        files.append(parts[1])
-    return files
-cvsfiles = cvs_entries(dir)
+def git_entries(file):
+    p = subprocess.Popen(['git', 'ls-files'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+    (out, err) = p.communicate(None)
+    p.wait()
+    if err:
+        print >> sys.stderr, "%s: %s" % (sys.argv[0], err)
+        sys.exit(1)
+    return out.split('\n')
+gitfiles = git_entries(dir)
 
 def blacklisted(file):
     if file == os.path.basename(spec):
         return True
 
-    if file in [ '.', '..', 'CVS', 'TODO']:
+    if file in [ '.', '..', '.git', 'CVS', 'TODO']:
         return True
 
     if os.path.isdir(file):
@@ -78,8 +77,8 @@ for file in os.listdir(dir):
     if blacklisted(file):
         continue
 
-    if not file in cvsfiles:
-        print "Not in cvs: %s" % file
+    if not file in gitfiles:
+        print "Not in repo: %s" % file
         continue
 
     if file not in files:
@@ -88,5 +87,5 @@ for file in os.listdir(dir):
 
 if obsolete:
     print
-    print "cvs rm -f %s" % " ".join(obsolete)
-    print "cvs commit -m '- drop obsolete files' %s" % " ".join(obsolete)
+    print "git rm %s" % " ".join(obsolete)
+    print "git commit -m '- drop obsolete files' %s" % " ".join(obsolete)
This page took 0.031764 seconds and 4 git commands to generate.