def main(): parser = OptionParser(usage=USAGE) parser.add_option('-l', '--locate', dest='use_locate', action='store_true', help='use locate(1) to find repositories') parser.add_option('-w', '--walk', dest='use_walk', action='store_true', help='manually walk file tree to find repositories') parser.add_option('-t', '--tracked', dest='ignore_untracked', action='store_true', help='ignore untracked files in repositories') (options, args) = parser.parse_args() if not args: parser.print_help() exit(2) if options.use_locate and options.use_walk: sys.stderr.write('Error: you cannot specify both "-l" and "-w"\n') exit(2) if options.use_walk: find_repos = scanner.find_repos_by_walking else: find_repos = scanner.find_repos_with_locate repos = set() for path in args: path = os.path.abspath(path) if not os.path.isdir(path): sys.stderr.write('Error: not a directory: %s\n' % (path, )) continue repos.update(find_repos(path)) repos = sorted(repos) report = '' for status in scanner.scan_repos( repos, ignore_untracked=options.ignore_untracked): if status['touched']: report += '%s %s (%s)\n' % (status['path'], status['status'], status['vcs']) if report: if sys.platform.startswith('linux'): notify_linux(report) else: raise NotImplementedError( 'Notification is not implemented for this system')
def main(): parser = OptionParser(usage=USAGE) parser.add_option('-l', '--locate', dest='use_locate', action='store_true', help='use locate(1) to find repositories') parser.add_option('-v', '--verbose', action='store_true', help='for each repository print it\'s status') parser.add_option('-a', '--all', action='store_true', dest='print_all', help='print every repository whether changed or not') parser.add_option('-w', '--walk', dest='use_walk', action='store_true', help='manually walk file tree to find repositories') parser.add_option('-t', '--tracked', dest='ignore_untracked', action='store_true', help='ignore untracked files in repositories') parser.add_option('-r', '--remote', dest='ignore_no_remote', action='store_true', help='ignore repositories with no remote') (options, args) = parser.parse_args() if not args: parser.print_help() exit(2) if options.use_locate and options.use_walk: sys.stderr.write('Error: you cannot specify both "-l" and "-w"\n') exit(2) if options.use_walk: find_repos = scanner.find_repos_by_walking else: find_repos = scanner.find_repos_with_locate repos = set() for path in args: path = os.path.abspath(path) if not os.path.isdir(path): sys.stderr.write('Error: not a directory: %s\n' % (path,)) continue repos.update(find_repos(path)) repos = sorted(repos) for status in scanner.scan_repos(repos, ignore_untracked=options.ignore_untracked, ignore_no_remote=options.ignore_no_remote): if status['touched'] or options.print_all: status_char = '*' if status['touched'] else ' ' print status_char, status['path'], status['status'], '('+status['vcs']+')' if options.verbose: print status['output']
def main(): parser = OptionParser(usage=USAGE) parser.add_option('-l', '--locate', dest='use_locate', action='store_true', help='use locate(1) to find repositories') parser.add_option('-w', '--walk', dest='use_walk', action='store_true', help='manually walk file tree to find repositories') parser.add_option('-t', '--tracked', dest='ignore_untracked', action='store_true', help='ignore untracked files in repositories') (options, args) = parser.parse_args() if not args: parser.print_help() exit(2) if options.use_locate and options.use_walk: sys.stderr.write('Error: you cannot specify both "-l" and "-w"\n') exit(2) if options.use_walk: find_repos = scanner.find_repos_by_walking else: find_repos = scanner.find_repos_with_locate repos = set() for path in args: path = os.path.abspath(path) if not os.path.isdir(path): sys.stderr.write('Error: not a directory: %s\n' % (path,)) continue repos.update(find_repos(path)) repos = sorted(repos) report = '' for status in scanner.scan_repos(repos, ignore_untracked=options.ignore_untracked): if status['touched']: report += '%s %s (%s)\n' % (status['path'], status['status'], status['vcs']) if report: if sys.platform.startswith('linux'): notify_linux(report) else: raise NotImplementedError('Notification is not implemented for this system')