X-Git-Url: http://git.pld-linux.org/?p=packages%2Frpm-build-tools.git;a=blobdiff_plain;f=check-unused-files.py;h=4ecc6a95816a7a062ca0d185f2e62166d44d2fd3;hp=6e26ea3b5cc31c74c11d75c5765c097d07d93651;hb=1d8d84a580565981baeefff8fb3677fd644aac9b;hpb=1e0688bb652ece22267c381b74286ed247ef090b diff --git a/check-unused-files.py b/check-unused-files.py old mode 100644 new mode 100755 index 6e26ea3..4ecc6a9 --- a/check-unused-files.py +++ b/check-unused-files.py @@ -38,19 +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 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): @@ -62,17 +72,20 @@ def blacklisted(file): return False - for file in os.listdir(dir): file = os.path.basename(file) if blacklisted(file): continue + if not file in gitfiles: + print "Not in repo: %s" % file + continue + if file not in files: print "Obsolete file: %s" % file obsolete.append(file) 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)