Print this page
9803 pbchk could use a -c option
9825 pbchk -b option should be -p

Split Close
Expand all
Collapse all
          --- old/usr/src/tools/scripts/git-pbchk.py
          +++ new/usr/src/tools/scripts/git-pbchk.py
↓ open down ↓ 10 lines elided ↑ open up ↑
  11   11  #
  12   12  #  You should have received a copy of the GNU General Public License
  13   13  #  along with this program; if not, write to the Free Software
  14   14  #  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15   15  #
  16   16  
  17   17  #
  18   18  # Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  19   19  # Copyright 2008, 2012 Richard Lowe
  20   20  # Copyright 2014 Garrett D'Amore <garrett@damore.org>
  21      -# Copyright (c) 2014, Joyent, Inc.
  22   21  # Copyright (c) 2015, 2016 by Delphix. All rights reserved.
  23   22  # Copyright 2016 Nexenta Systems, Inc.
       23 +# Copyright 2018 Joyent, Inc.
  24   24  #
  25   25  
  26   26  import getopt
  27   27  import os
  28   28  import re
  29   29  import subprocess
  30   30  import sys
  31   31  import tempfile
  32   32  
  33   33  from cStringIO import StringIO
↓ open down ↓ 330 lines elided ↑ open up ↑
 364  364              jstyle,
 365  365              keywords,
 366  366              manlint,
 367  367              mapfilechk,
 368  368              wscheck]
 369  369      run_checks(root, parent, cmds)
 370  370  
 371  371  
 372  372  def main(cmd, args):
 373  373      parent_branch = None
      374 +    checkname = None
 374  375  
 375  376      try:
 376      -        opts, args = getopt.getopt(args, 'b:')
      377 +        opts, args = getopt.getopt(args, 'c:p:')
 377  378      except getopt.GetoptError, e:
 378  379          sys.stderr.write(str(e) + '\n')
 379      -        sys.stderr.write("Usage: %s [-b branch] [path...]\n" % cmd)
      380 +        sys.stderr.write("Usage: %s [-c check] [-p branch] [path...]\n" % cmd)
 380  381          sys.exit(1)
 381  382  
 382  383      for opt, arg in opts:
      384 +        # backwards compatibility
 383  385          if opt == '-b':
 384  386              parent_branch = arg
      387 +        elif opt == '-c':
      388 +            checkname = arg
      389 +        elif opt == '-p':
      390 +            parent_branch = arg
 385  391  
 386  392      if not parent_branch:
 387  393          parent_branch = git_parent_branch(git_branch())
 388  394  
 389      -    func = nits
 390      -    if cmd == 'git-pbchk':
 391      -        func = pbchk
      395 +    if checkname is None:
      396 +        if cmd == 'git-pbchk':
      397 +            checkname= 'pbchk'
      398 +        else:
      399 +            checkname = 'nits'
      400 +
      401 +    if checkname == 'pbchk':
 392  402          if args:
 393  403              sys.stderr.write("only complete workspaces may be pbchk'd\n");
 394  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)
 395  410  
 396      -    func(git_root(), parent_branch, args)
 397      -
 398  411  if __name__ == '__main__':
 399  412      try:
 400  413          main(os.path.basename(sys.argv[0]), sys.argv[1:])
 401  414      except GitError, e:
 402  415          sys.stderr.write("failed to run git:\n %s\n" % str(e))
 403  416          sys.exit(1)
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX