1 #!@PYTHON@
2 #
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License version 2
5 # as published by the Free Software Foundation.
6 #
7 # This program is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 # GNU General Public License for more details.
11 #
12 # You should have received a copy of the GNU General Public License
13 # along with this program; if not, write to the Free Software
14 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
15 #
16
17 #
18 # Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
19 # Copyright 2008, 2012 Richard Lowe
20 # Copyright 2014 Garrett D'Amore <garrett@damore.org>
21 # Copyright (c) 2014, Joyent, Inc.
22 # Copyright (c) 2015, 2016 by Delphix. All rights reserved.
23 # Copyright 2016 Nexenta Systems, Inc.
24 #
25
26 import getopt
27 import os
28 import re
29 import subprocess
30 import sys
31 import tempfile
32
33 from cStringIO import StringIO
34
35 #
36 # Adjust the load path based on our location and the version of python into
37 # which it is being loaded. This assumes the normal onbld directory
38 # structure, where we are in bin/ and the modules are in
39 # lib/python(version)?/onbld/Scm/. If that changes so too must this.
40 #
41 sys.path.insert(1, os.path.join(os.path.dirname(__file__), "..", "lib",
42 "python%d.%d" % sys.version_info[:2]))
43
354 mapfilechk,
355 wscheck]
356 run_checks(root, parent, cmds, paths)
357
358
359 def pbchk(root, parent, paths):
360 cmds = [comchk,
361 copyright,
362 cstyle,
363 hdrchk,
364 jstyle,
365 keywords,
366 manlint,
367 mapfilechk,
368 wscheck]
369 run_checks(root, parent, cmds)
370
371
372 def main(cmd, args):
373 parent_branch = None
374
375 try:
376 opts, args = getopt.getopt(args, 'b:')
377 except getopt.GetoptError, e:
378 sys.stderr.write(str(e) + '\n')
379 sys.stderr.write("Usage: %s [-b branch] [path...]\n" % cmd)
380 sys.exit(1)
381
382 for opt, arg in opts:
383 if opt == '-b':
384 parent_branch = arg
385
386 if not parent_branch:
387 parent_branch = git_parent_branch(git_branch())
388
389 func = nits
390 if cmd == 'git-pbchk':
391 func = pbchk
392 if args:
393 sys.stderr.write("only complete workspaces may be pbchk'd\n");
394 sys.exit(1)
395
396 func(git_root(), parent_branch, args)
397
398 if __name__ == '__main__':
399 try:
400 main(os.path.basename(sys.argv[0]), sys.argv[1:])
401 except GitError, e:
402 sys.stderr.write("failed to run git:\n %s\n" % str(e))
403 sys.exit(1)
|
1 #!@PYTHON@
2 #
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License version 2
5 # as published by the Free Software Foundation.
6 #
7 # This program is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 # GNU General Public License for more details.
11 #
12 # You should have received a copy of the GNU General Public License
13 # along with this program; if not, write to the Free Software
14 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
15 #
16
17 #
18 # Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
19 # Copyright 2008, 2012 Richard Lowe
20 # Copyright 2014 Garrett D'Amore <garrett@damore.org>
21 # Copyright (c) 2015, 2016 by Delphix. All rights reserved.
22 # Copyright 2016 Nexenta Systems, Inc.
23 # Copyright 2018 Joyent, Inc.
24 #
25
26 import getopt
27 import os
28 import re
29 import subprocess
30 import sys
31 import tempfile
32
33 from cStringIO import StringIO
34
35 #
36 # Adjust the load path based on our location and the version of python into
37 # which it is being loaded. This assumes the normal onbld directory
38 # structure, where we are in bin/ and the modules are in
39 # lib/python(version)?/onbld/Scm/. If that changes so too must this.
40 #
41 sys.path.insert(1, os.path.join(os.path.dirname(__file__), "..", "lib",
42 "python%d.%d" % sys.version_info[:2]))
43
354 mapfilechk,
355 wscheck]
356 run_checks(root, parent, cmds, paths)
357
358
359 def pbchk(root, parent, paths):
360 cmds = [comchk,
361 copyright,
362 cstyle,
363 hdrchk,
364 jstyle,
365 keywords,
366 manlint,
367 mapfilechk,
368 wscheck]
369 run_checks(root, parent, cmds)
370
371
372 def main(cmd, args):
373 parent_branch = None
374 checkname = None
375
376 try:
377 opts, args = getopt.getopt(args, 'c:p:')
378 except getopt.GetoptError, e:
379 sys.stderr.write(str(e) + '\n')
380 sys.stderr.write("Usage: %s [-c check] [-p branch] [path...]\n" % cmd)
381 sys.exit(1)
382
383 for opt, arg in opts:
384 # backwards compatibility
385 if opt == '-b':
386 parent_branch = arg
387 elif opt == '-c':
388 checkname = arg
389 elif opt == '-p':
390 parent_branch = arg
391
392 if not parent_branch:
393 parent_branch = git_parent_branch(git_branch())
394
395 if checkname is None:
396 if cmd == 'git-pbchk':
397 checkname= 'pbchk'
398 else:
399 checkname = 'nits'
400
401 if checkname == 'pbchk':
402 if args:
403 sys.stderr.write("only complete workspaces may be pbchk'd\n");
404 sys.exit(1)
405 pbchk(git_root(), parent_branch, None)
406 elif checkname == 'nits':
407 nits(git_root(), parent_branch, args)
408 else:
409 run_checks(git_root(), parent_branch, [eval(checkname)], args)
410
411 if __name__ == '__main__':
412 try:
413 main(os.path.basename(sys.argv[0]), sys.argv[1:])
414 except GitError, e:
415 sys.stderr.write("failed to run git:\n %s\n" % str(e))
416 sys.exit(1)
|