--- a/checker.py Sun Jul 17 23:42:38 2016 +0800
+++ b/checker.py Mon Jul 18 14:02:28 2016 +0800
def git_clone(url, dest):
- return run(['git', 'clone', '--depth', '1', url, dest])
+ return run(['git', 'clone', url, dest])
return run(['hg', 'clone', url, dest])
+def git_checkout(commit):
+ return run(['git', 'checkout', commit])
+ return run(['hg', 'update', commit])
return run(['git', 'status'])
-def execute(tmp, config):
+def execute(tmp, config, args):
if not prevalidate(config):
print('$ cd {}'.format(source))
+ if args.commit is not None:
+ if config['scm'] == 'git':
+ if not git_checkout(args.commit):
+ elif config['scm'] == 'hg':
+ if not hg_update(args.commit):
if config['scm'] == 'git':
+def wrapper(config, args):
print('# C&O job started: {}'.format(timestamp()))
tmp = mkdtemp(prefix='candolint.')
- if not execute(tmp, config):
+ if not execute(tmp, config, args):
print('# C&O job failed')
print('# C&O task: cleanup')
parser = ArgumentParser()
- helptext = 'project configuration file (YAML)'
- parser.add_argument('config', type=FileType('r'), help=helptext)
+ 'config', type=FileType('r'),
+ help='project configuration file (YAML)')
+ parser.add_argument('commit', nargs='?', help='commit to update to')
args = parser.parse_args()
config = yaml.safe_load(args.config)