Example #1
0
def main():  # pragma: no cover
  parser = optparse.OptionParser(usage=sys.modules[__name__].__doc__)
  parser.add_option('--no-cache', action='store_true',
                    help='Do not actually cache anything we calculate.')
  parser.add_option('--reset', action='store_true',
                    help='Reset the generation number cache and quit.')
  parser.add_option('-v', '--verbose', action='count', default=0,
                    help='Be verbose. Use more times for more verbosity.')
  opts, args = parser.parse_args()

  levels = [logging.ERROR, logging.INFO, logging.DEBUG]
  logging.basicConfig(level=levels[min(opts.verbose, len(levels) - 1)])

  # 'git number' should only be used on bots.
  if os.getenv('CHROME_HEADLESS') != '1':
    logging.error("'git-number' is an infrastructure tool that is only "
                  "intended to be used internally by bots. Developers should "
                  "use the 'Cr-Commit-Position' value in the commit's message.")
    return 1

  if opts.reset:
    clear_caches(on_disk=True)
    return

  try:
    targets = git.parse_commitrefs(*(args or ['HEAD']))
  except git.BadCommitRefException as e:
    parser.error(e)

  load_generation_numbers(targets)
  if not opts.no_cache:
    finalize(targets)

  print('\n'.join(map(str, map(get_num, targets))))
  return 0
Example #2
0
def main():  # pragma: no cover
  parser = optparse.OptionParser(usage=sys.modules[__name__].__doc__)
  parser.add_option('--no-cache', action='store_true',
                    help='Do not actually cache anything we calculate.')
  parser.add_option('--reset', action='store_true',
                    help='Reset the generation number cache and quit.')
  parser.add_option('-v', '--verbose', action='count', default=0,
                    help='Be verbose. Use more times for more verbosity.')
  opts, args = parser.parse_args()

  levels = [logging.ERROR, logging.INFO, logging.DEBUG]
  logging.basicConfig(level=levels[min(opts.verbose, len(levels) - 1)])

  try:
    if opts.reset:
      clear_caches(on_disk=True)
      return

    try:
      targets = git.parse_commitrefs(*(args or ['HEAD']))
    except git.BadCommitRefException as e:
      parser.error(e)

    load_generation_numbers(targets)
    if not opts.no_cache:
      finalize(targets)

    print '\n'.join(map(str, map(get_num, targets)))
    return 0
  except KeyboardInterrupt:
    return 1
Example #3
0
def main():  # pragma: no cover
  parser = optparse.OptionParser(usage=sys.modules[__name__].__doc__)
  parser.add_option('--no-cache', action='store_true',
                    help='Do not actually cache anything we calculate.')
  parser.add_option('--reset', action='store_true',
                    help='Reset the generation number cache and quit.')
  parser.add_option('-v', '--verbose', action='count', default=0,
                    help='Be verbose. Use more times for more verbosity.')
  opts, args = parser.parse_args()

  levels = [logging.ERROR, logging.INFO, logging.DEBUG]
  logging.basicConfig(level=levels[min(opts.verbose, len(levels) - 1)])

  # 'git number' should only be used on bots.
  if os.getenv('CHROME_HEADLESS') != '1':
    logging.error("'git-number' is an infrastructure tool that is only "
                  "intended to be used internally by bots. Developers should "
                  "use the 'Cr-Commit-Position' value in the commit's message.")
    return 1

  if opts.reset:
    clear_caches(on_disk=True)
    return

  try:
    targets = git.parse_commitrefs(*(args or ['HEAD']))
  except git.BadCommitRefException as e:
    parser.error(e)

  load_generation_numbers(targets)
  if not opts.no_cache:
    finalize(targets)

  print '\n'.join(map(str, map(get_num, targets)))
  return 0
Example #4
0
def main():  # pragma: no cover
  parser = optparse.OptionParser(usage=sys.modules[__name__].__doc__)
  parser.add_option('--no-cache', action='store_true',
                    help='Do not actually cache anything we calculate.')
  parser.add_option('--reset', action='store_true',
                    help='Reset the generation number cache and quit.')
  parser.add_option('-v', '--verbose', action='count', default=0,
                    help='Be verbose. Use more times for more verbosity.')
  opts, args = parser.parse_args()

  levels = [logging.ERROR, logging.INFO, logging.DEBUG]
  logging.basicConfig(level=levels[min(opts.verbose, len(levels) - 1)])

  try:
    if opts.reset:
      clear_caches(on_disk=True)
      return

    try:
      targets = git.parse_commitrefs(*(args or ['HEAD']))
    except git.BadCommitRefException as e:
      parser.error(e)

    load_generation_numbers(targets)
    if not opts.no_cache:
      finalize(targets)

    print '\n'.join(map(str, map(get_num, targets)))
    return 0
  except KeyboardInterrupt:
    return 1