示例#1
0
def main():
    usage = "git stacktrace [<options>] [<RANGE>] < stacktrace from stdin"
    description = "Lookup commits related to a given stacktrace"
    parser = argparse.ArgumentParser(usage=usage, description=description)
    range_group = parser.add_mutually_exclusive_group()
    range_group.add_argument('--since',
                             metavar="<date1>",
                             help='show commits '
                             'more recent then a specific date (from git-log)')
    range_group.add_argument('range',
                             nargs='?',
                             help='git commit range to use')
    parser.add_argument('-f',
                        '--fast',
                        action="store_true",
                        help='Speed things up by not running '
                        'pickaxe if cannot find the file')
    parser.add_argument(
        '-p',
        '--path',
        nargs='?',
        help='Git path, if using --since, use this to specify which branch '
        'to run on.')
    parser.add_argument(
        '--version',
        action="version",
        version='%s version %s' %
        (os.path.split(sys.argv[0])[-1], git_stacktrace.__version__))
    args = parser.parse_args()

    if args.since:
        git_range = api.convert_since(args.since, path=args.path)
        print >> sys.stderr, "commit range: %s" % git_range
    else:
        if args.range is None:
            print "Error: Missing range and since, must use one\n"
            parser.print_help()
            sys.exit(1)
        git_range = args.range

    if not api.valid_range(git_range):
        print "Found no commits in '%s'" % git_range
        sys.exit(1)

    if not select.select([sys.stdin], [], [], 0.0)[0]:
        raise Exception("No input found in stdin")
    blob = sys.stdin.readlines()
    traceback = api.parse_trace(blob)

    print traceback

    results = api.lookup_stacktrace(traceback, git_range, fast=args.fast)

    for r in results.get_sorted_results():
        print ""
        print r

    if len(results.get_sorted_results()) == 0:
        print "No matches found"
示例#2
0
    def validate(self):
        if not self.type:
            return None

        if self.type == 'by-date':
            if not self.since:
                return 'Missing `since` value. Plese specify a date.'
            self.git_range = api.convert_since(self.since, branch=self.branch)
            if not api.valid_range(self.git_range):
                return "Found no commits in '%s'" % self.git_range
        elif self.type == 'by-range':
            self.git_range = self.range
            if not api.valid_range(self.git_range):
                return "Found no commits in '%s'" % self.git_range
        else:
            return 'Invalid `type` value. Expected `by-date` or `by-range`.'
        return None
示例#3
0
    def validate(self):
        if not self.type:
            return None

        if self.type == 'by-date':
            if not self.since:
                return 'Missing `since` value. Plese specify a date.'
            self.git_range = api.convert_since(self.since, branch=self.branch)
            if not api.valid_range(self.git_range):
                return "Found no commits in '%s'" % self.git_range
        elif self.type == 'by-range':
            self.git_range = self.range
            if not api.valid_range(self.git_range):
                return "Found no commits in '%s'" % self.git_range
        else:
            return 'Invalid `type` value. Expected `by-date` or `by-range`.'
        return None
示例#4
0
def main():
    usage = "git stacktrace [<options>] [<RANGE>] < stacktrace from stdin"
    description = "Lookup commits related to a given stacktrace"
    parser = argparse.ArgumentParser(usage=usage, description=description)
    range_group = parser.add_mutually_exclusive_group()
    range_group.add_argument('--since', metavar="<date1>", help='show commits '
                             'more recent then a specific date (from git-log)')
    range_group.add_argument('range', nargs='?', help='git commit range to use')
    parser.add_argument('-f', '--fast', action="store_true", help='Speed things up by not running '
                        'pickaxe if cannot find the file')
    parser.add_argument('-p', '--path', nargs='?', help='Git path, if using --since, use this to specify which branch '
                        'to run on.')
    parser.add_argument('--version', action="version",
                        version='%s version %s' % (os.path.split(sys.argv[0])[-1], git_stacktrace.__version__))
    args = parser.parse_args()

    if args.since:
        git_range = api.convert_since(args.since, path=args.path)
        print >> sys.stderr, "commit range: %s" % git_range
    else:
        if args.range is None:
            print "Error: Missing range and since, must use one\n"
            parser.print_help()
            sys.exit(1)
        git_range = args.range

    if not api.valid_range(git_range):
        print "Found no commits in '%s'" % git_range
        sys.exit(1)

    if not select.select([sys.stdin], [], [], 0.0)[0]:
        raise Exception("No input found in stdin")
    blob = sys.stdin.readlines()
    traceback = api.Traceback(blob)

    print "Traceback:"
    print traceback

    results = api.lookup_stacktrace(traceback, git_range, fast=args.fast)

    for r in results.get_sorted_results():
        print ""
        print r

    if len(results.get_sorted_results()) == 0:
        print "No matches found"
 def test_convert_since(self, mocked_command):
     expected = "HASH1..HASH2"
     mocked_command.return_value = expected
     self.assertEquals(expected, api.convert_since('1.day'))
示例#6
0
 def test_convert_since(self, mocked_command):
     expected = "HASH1..HASH2"
     mocked_command.return_value = expected
     self.assertEqual(expected, api.convert_since('1.day'))
def main():
    usage = "git stacktrace [<options>] [<RANGE>] < stacktrace from stdin"
    description = "Lookup commits related to a given stacktrace."
    parser = argparse.ArgumentParser(usage=usage, description=description)
    range_group = parser.add_mutually_exclusive_group()
    range_group.add_argument('--since',
                             metavar="<date1>",
                             help='show commits '
                             'more recent than a specific date (from git-log)')
    range_group.add_argument('range',
                             nargs='?',
                             help='git commit range to use')
    range_group.add_argument(
        '--server',
        action="store_true",
        help='start a '
        'webserver to visually interact with git-stacktrace')
    parser.add_argument('--port',
                        default=os.environ.get('GIT_STACKTRACE_PORT', 8080),
                        type=int,
                        help='Server port')
    parser.add_argument(
        '-f',
        '--fast',
        action="store_true",
        help='Speed things up by not running '
        'pickaxe if the file for a line of code cannot be found')
    parser.add_argument(
        '-b',
        '--branch',
        nargs='?',
        help='Git branch. If using --since, use this to '
        'specify which branch to run since on. Runs on current branch by default'
    )
    parser.add_argument(
        '--version',
        action="version",
        version='%s version %s' %
        (os.path.split(sys.argv[0])[-1], git_stacktrace.__version__))
    parser.add_argument('-d',
                        '--debug',
                        action='store_true',
                        help='Enable debug logging')
    args = parser.parse_args()

    logging.basicConfig(format='%(name)s:%(funcName)s:%(lineno)s: %(message)s')
    if args.debug:
        logging.getLogger().setLevel(logging.DEBUG)

    if args.server:
        print("Starting httpd on port %s..." % args.port)
        httpd = make_server('', args.port, server.application)
        try:
            httpd.serve_forever()
        except KeyboardInterrupt:
            sys.exit(0)

    if args.since:
        git_range = api.convert_since(args.since, branch=args.branch)
        print("commit range: %s" % git_range, file=sys.stderr)
    else:
        if args.range is None:
            print("Error: Missing range and since, must use one\n")
            parser.print_help()
            sys.exit(1)
        git_range = args.range

    if not api.valid_range(git_range):
        print("Found no commits in '%s'" % git_range)
        sys.exit(1)

    if not select.select([sys.stdin], [], [], 0.0)[0]:
        raise Exception("No input found in stdin")
    blob = sys.stdin.readlines()
    traceback = api.parse_trace(blob)

    print(traceback)

    results = api.lookup_stacktrace(traceback, git_range, fast=args.fast)

    for r in results.get_sorted_results():
        print("")
        print(r)

    if len(results.get_sorted_results()) == 0:
        print("No matches found")
示例#8
0
def main():
    usage = "git stacktrace [<options>] [<RANGE>] < stacktrace from stdin"
    description = "Lookup commits related to a given stacktrace."
    parser = argparse.ArgumentParser(usage=usage, description=description)
    range_group = parser.add_mutually_exclusive_group()
    range_group.add_argument('--since', metavar="<date1>", help='show commits '
                             'more recent than a specific date (from git-log)')
    range_group.add_argument('range', nargs='?', help='git commit range to use')
    range_group.add_argument('--server', action="store_true", help='start a '
                             'webserver to visually interact with git-stacktrace')
    parser.add_argument('--port', default=os.environ.get('GIT_STACKTRACE_PORT', 8080),
                        type=int, help='Server port')
    parser.add_argument('-f', '--fast', action="store_true", help='Speed things up by not running '
                        'pickaxe if the file for a line of code cannot be found')
    parser.add_argument('-b', '--branch', nargs='?', help='Git branch. If using --since, use this to '
                        'specify which branch to run since on. Runs on current branch by default')
    parser.add_argument('--version', action="version",
                        version='%s version %s' % (os.path.split(sys.argv[0])[-1], git_stacktrace.__version__))
    parser.add_argument('-d', '--debug', action='store_true', help='Enable debug logging')
    args = parser.parse_args()

    logging.basicConfig(format='%(name)s:%(funcName)s:%(lineno)s: %(message)s')
    if args.debug:
        logging.getLogger().setLevel(logging.DEBUG)

    if args.server:
        print("Starting httpd on port %s..." % args.port)
        httpd = make_server('', args.port, server.application)
        try:
            httpd.serve_forever()
        except KeyboardInterrupt:
            sys.exit(0)

    if args.since:
        git_range = api.convert_since(args.since, branch=args.branch)
        print("commit range: %s" % git_range, file=sys.stderr)
    else:
        if args.range is None:
            print("Error: Missing range and since, must use one\n")
            parser.print_help()
            sys.exit(1)
        git_range = args.range

    if not api.valid_range(git_range):
        print("Found no commits in '%s'" % git_range)
        sys.exit(1)

    if not select.select([sys.stdin], [], [], 0.0)[0]:
        raise Exception("No input found in stdin")
    blob = sys.stdin.readlines()
    traceback = api.parse_trace(blob)

    print(traceback)

    results = api.lookup_stacktrace(traceback, git_range, fast=args.fast)

    for r in results.get_sorted_results():
        print("")
        print(r)

    if len(results.get_sorted_results()) == 0:
        print("No matches found")