Coder Social home page Coder Social logo

pinterest / git-stacktrace Goto Github PK

View Code? Open in Web Editor NEW
157.0 13.0 24.0 166 KB

Easily figure out which git commit caused a given stacktrace

Home Page: https://pypi.python.org/pypi/git-stacktrace

License: Apache License 2.0

Python 88.93% HTML 11.07%
git

git-stacktrace's Introduction

git-stacktrace

git-stacktrace is a tool to help you associate git commits with stacktraces.

It helps you identify related commits by looking at:

  • commits in given range that touched files present in the stacktrace
  • commits in given range that added/removed code present in the stacktrace

Supported Languages

Development

Run tests with: tox

Installation

$ pip install git_stacktrace

Usage

Run git stacktrace within a git initialized directory.

usage: git stacktrace [<options>] [<RANGE>] < stacktrace from stdin

Lookup commits related to a given stacktrace.

positional arguments:
  range                 git commit range to use

optional arguments:
  -h, --help            show this help message and exit
  --since <date1>       show commits more recent than a specific date (from
                        git-log)
  --server              start a webserver to visually interact with git-
                        stacktrace
  --port PORT           Server port
  -f, --fast            Speed things up by not running pickaxe if the file for
                        a line of code cannot be found
  -b [BRANCH], --branch [BRANCH]
                        Git branch. If using --since, use this to specify
                        which branch to run since on. Runs on current branch
                        by default
  --version             show program's version number and exit
  -d, --debug           Enable debug logging

For the Python API see: git_stacktrace/api.py

To run as a web server: git stacktrace --server --port=8080 or GIT_STACKTRACE_PORT=8080 git stacktrace --server

Use the web server as an API:

$ curl \
  -d '{"option-type":"by-date", "since":"1.day", "trace":"..."}' \
  -H "Content-Type: application/json" \
  -X POST http://localhost:8080/

Examples

Example output:

$ git stacktrace --since=1.day < trace
Traceback (most recent call last):
 File "webapp/framework/resource.py", line 72, in _call
   result = getattr(self, method_name)()
 File "webapp/resources/interests_resource.py", line 232, in get
   if self.options['from_navigate'] == "true":
KeyError


commit da39a3ee5e6b4b0d3255bfef95601890afd80709
Commit Date: Tue, 19 Jul 2016 14:18:08 -0700
Author:      John Doe <[email protected]>
Subject:     break interest resource
Link:        https://example.com/D1000
Files Modified:
   - webapp/resources/interests_resource.py:232
Lines Added:
   - "if self.options['from_navigate'] == "true":"

git-stacktrace's People

Contributors

jogo avatar joshenders avatar jparise avatar ryan953 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

git-stacktrace's Issues

Multiple language support

Right now git-stacktrace only supports python stacktraces, but it would be a useful tool for other languages. Have we considered adding this?

Attempting to run the tool results in a syntax error

I tried running the tool on a Ubuntu vagrant box and an Alpine docker container, however both resulted in the following error.

Trace

Traceback (most recent call last):
  File "/home/vagrant/.local/bin/git-stacktrace", line 7, in <module>
    from git_stacktrace.cmd import main
  File "/home/vagrant/.local/lib/python2.7/site-packages/git_stacktrace/cmd.py", line 10, in <module>
    from git_stacktrace import api
  File "/home/vagrant/.local/lib/python2.7/site-packages/git_stacktrace/api.py", line 22, in <module>
    from git_stacktrace import parse_trace
  File "/home/vagrant/.local/lib/python2.7/site-packages/git_stacktrace/parse_trace.py", line 38
    class Traceback(object, metaclass=abc.ABCMeta):
                                     ^
SyntaxError: invalid syntax

Environment 1 (Vagrant)

  • git version 2.17.1
  • Python 2.7.17
  • pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7)
  • No LSB modules are available.
    Distributor ID: Ubuntu
    Description: Ubuntu 18.04.5 LTS
    Release: 18.04
    Codename: bionic

Environment 2 (Docker)

  • Alpine Linux 3.13.6
  • Docker version 20.10.8, build 3967b7d

Improve the reliability of testing by reviewing tox configuration and adding more documentation

The README is currently a little light on details around testing. It recommends running tox in the base dir of the repo to initiate testing but this is currently unreliable/not working for me on several different systems due to various inconsistent errors.

As I'm new to tox, and there is no additional documentation, it's unclear to me if this is a tox issue or an issue with my development environment. It would be great if this could be documented a little more thoughtfully or if the configuration can be updated and tested on a few different platforms to improve reliability.

Here's one example error after installing tox with pip and running tox:

jenders@dev-jenders:~/src/git-stacktrace$ tox
GLOB sdist-make: /home/jenders/src/git-stacktrace/setup.py
py27 create: /home/jenders/src/git-stacktrace/.tox/py27
py27 installdeps: -r/home/jenders/src/git-stacktrace/test-requirements.txt
ERROR: invocation failed (exit code 1), logfile: /home/jenders/src/git-stacktrace/.tox/py27/log/py27-1.log
===================================================================================================================== log start =====================================================================================================================
Collecting testtools (from -r /home/jenders/src/git-stacktrace/test-requirements.txt (line 1))
  Using cached https://pypi-pim.pinadmin.com/packages/87/74/a4d55da28d7bba6d6f49430f22a62afd8472cb24a63fa61daef80d3e821b/testtools-2.3.0-py2.py3-none-any.whl
Collecting flake8 (from -r /home/jenders/src/git-stacktrace/test-requirements.txt (line 2))
  Using cached https://pypi-pim.pinadmin.com/packages/26/de/3f815a99d86eb10464ea7bd6059c0172c7ca97d4bdcfca41051b388a653b/flake8-3.7.8-py2.py3-none-any.whl
Collecting pytest (from -r /home/jenders/src/git-stacktrace/test-requirements.txt (line 3))
  Using cached https://pypi-pim.pinadmin.com/packages/e3/89/bdc4ee34896c03e1b42f80a5e1539443df4715f96d45cd7f4118b7c30229/pytest-5.2.0.tar.gz
  Running setup.py (path:/tmp/pip-build-cKHgML/pytest/setup.py) egg_info for package pytest produced metadata for project name unknown. Fix your #egg=pytest fragments.
Collecting python-subunit (from -r /home/jenders/src/git-stacktrace/test-requirements.txt (line 4))
  Using cached https://pypi-pim.pinadmin.com/packages/ee/3a/b8a93e1f5b9a9f7e0a7630146f1c62878b6949ac5e4bac6ae2ae13fa9f83/python_subunit-1.3.0-py2.py3-none-any.whl
Collecting fixtures (from -r /home/jenders/src/git-stacktrace/test-requirements.txt (line 5))
  Using cached https://pypi-pim.pinadmin.com/packages/a8/28/7eed6bf76792f418029a18d5b2ace87ce7562927cdd00f1cefe481cd148f/fixtures-3.0.0-py2.py3-none-any.whl
Collecting mock (from -r /home/jenders/src/git-stacktrace/test-requirements.txt (line 6))
  Using cached https://pypi-pim.pinadmin.com/packages/05/d2/f94e68be6b17f46d2c353564da56e6fb89ef09faeeff3313a046cb810ca9/mock-3.0.5-py2.py3-none-any.whl
Collecting sphinx (from -r /home/jenders/src/git-stacktrace/test-requirements.txt (line 7))
  Using cached https://pypi-pim.pinadmin.com/packages/76/42/a4465a0080e545cd152f7d3f16229d5e1300183fcb1067e4ec7e639b8605/Sphinx-2.2.0.tar.gz
    Complete output from command python setup.py egg_info:
    ERROR: Sphinx requires at least Python 3.5 to run.

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-cKHgML/sphinx/
You are using pip version 8.1.2, however version 19.2.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

====================================================================================================================== log end ======================================================================================================================
ERROR: could not install deps [-r/home/jenders/src/git-stacktrace/test-requirements.txt]; v = InvocationError(u'/home/jenders/src/git-stacktrace/.tox/py27/bin/pip install -U -r/home/jenders/src/git-stacktrace/test-requirements.txt', 1)
py36 create: /home/jenders/src/git-stacktrace/.tox/py36
ERROR: InterpreterNotFound: python3.6
flake8 create: /home/jenders/src/git-stacktrace/.tox/flake8
flake8 installdeps: -r/home/jenders/src/git-stacktrace/test-requirements.txt
ERROR: invocation failed (exit code 1), logfile: /home/jenders/src/git-stacktrace/.tox/flake8/log/flake8-1.log
===================================================================================================================== log start =====================================================================================================================
Collecting testtools (from -r /home/jenders/src/git-stacktrace/test-requirements.txt (line 1))
  Using cached https://pypi-pim.pinadmin.com/packages/87/74/a4d55da28d7bba6d6f49430f22a62afd8472cb24a63fa61daef80d3e821b/testtools-2.3.0-py2.py3-none-any.whl
Collecting flake8 (from -r /home/jenders/src/git-stacktrace/test-requirements.txt (line 2))
  Using cached https://pypi-pim.pinadmin.com/packages/26/de/3f815a99d86eb10464ea7bd6059c0172c7ca97d4bdcfca41051b388a653b/flake8-3.7.8-py2.py3-none-any.whl
Collecting pytest (from -r /home/jenders/src/git-stacktrace/test-requirements.txt (line 3))
  Using cached https://pypi-pim.pinadmin.com/packages/e3/89/bdc4ee34896c03e1b42f80a5e1539443df4715f96d45cd7f4118b7c30229/pytest-5.2.0.tar.gz
  Running setup.py (path:/tmp/pip-build-CKpwth/pytest/setup.py) egg_info for package pytest produced metadata for project name unknown. Fix your #egg=pytest fragments.
Collecting python-subunit (from -r /home/jenders/src/git-stacktrace/test-requirements.txt (line 4))
  Using cached https://pypi-pim.pinadmin.com/packages/ee/3a/b8a93e1f5b9a9f7e0a7630146f1c62878b6949ac5e4bac6ae2ae13fa9f83/python_subunit-1.3.0-py2.py3-none-any.whl
Collecting fixtures (from -r /home/jenders/src/git-stacktrace/test-requirements.txt (line 5))
  Using cached https://pypi-pim.pinadmin.com/packages/a8/28/7eed6bf76792f418029a18d5b2ace87ce7562927cdd00f1cefe481cd148f/fixtures-3.0.0-py2.py3-none-any.whl
Collecting mock (from -r /home/jenders/src/git-stacktrace/test-requirements.txt (line 6))
  Using cached https://pypi-pim.pinadmin.com/packages/05/d2/f94e68be6b17f46d2c353564da56e6fb89ef09faeeff3313a046cb810ca9/mock-3.0.5-py2.py3-none-any.whl
Collecting sphinx (from -r /home/jenders/src/git-stacktrace/test-requirements.txt (line 7))
  Using cached https://pypi-pim.pinadmin.com/packages/76/42/a4465a0080e545cd152f7d3f16229d5e1300183fcb1067e4ec7e639b8605/Sphinx-2.2.0.tar.gz
    Complete output from command python setup.py egg_info:
    ERROR: Sphinx requires at least Python 3.5 to run.

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-CKpwth/sphinx/
You are using pip version 8.1.2, however version 19.2.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

====================================================================================================================== log end ======================================================================================================================
ERROR: could not install deps [-r/home/jenders/src/git-stacktrace/test-requirements.txt]; v = InvocationError(u'/home/jenders/src/git-stacktrace/.tox/flake8/bin/pip install -U -r/home/jenders/src/git-stacktrace/test-requirements.txt', 1)
docs create: /home/jenders/src/git-stacktrace/.tox/docs
docs installdeps: -r/home/jenders/src/git-stacktrace/test-requirements.txt
ERROR: invocation failed (exit code 1), logfile: /home/jenders/src/git-stacktrace/.tox/docs/log/docs-1.log
===================================================================================================================== log start =====================================================================================================================
Collecting testtools (from -r /home/jenders/src/git-stacktrace/test-requirements.txt (line 1))
  Using cached https://pypi-pim.pinadmin.com/packages/87/74/a4d55da28d7bba6d6f49430f22a62afd8472cb24a63fa61daef80d3e821b/testtools-2.3.0-py2.py3-none-any.whl
Collecting flake8 (from -r /home/jenders/src/git-stacktrace/test-requirements.txt (line 2))
  Using cached https://pypi-pim.pinadmin.com/packages/26/de/3f815a99d86eb10464ea7bd6059c0172c7ca97d4bdcfca41051b388a653b/flake8-3.7.8-py2.py3-none-any.whl
Collecting pytest (from -r /home/jenders/src/git-stacktrace/test-requirements.txt (line 3))
  Using cached https://pypi-pim.pinadmin.com/packages/e3/89/bdc4ee34896c03e1b42f80a5e1539443df4715f96d45cd7f4118b7c30229/pytest-5.2.0.tar.gz
  Running setup.py (path:/tmp/pip-build-8J4LSc/pytest/setup.py) egg_info for package pytest produced metadata for project name unknown. Fix your #egg=pytest fragments.
Collecting python-subunit (from -r /home/jenders/src/git-stacktrace/test-requirements.txt (line 4))
  Using cached https://pypi-pim.pinadmin.com/packages/ee/3a/b8a93e1f5b9a9f7e0a7630146f1c62878b6949ac5e4bac6ae2ae13fa9f83/python_subunit-1.3.0-py2.py3-none-any.whl
Collecting fixtures (from -r /home/jenders/src/git-stacktrace/test-requirements.txt (line 5))
  Using cached https://pypi-pim.pinadmin.com/packages/a8/28/7eed6bf76792f418029a18d5b2ace87ce7562927cdd00f1cefe481cd148f/fixtures-3.0.0-py2.py3-none-any.whl
Collecting mock (from -r /home/jenders/src/git-stacktrace/test-requirements.txt (line 6))
  Using cached https://pypi-pim.pinadmin.com/packages/05/d2/f94e68be6b17f46d2c353564da56e6fb89ef09faeeff3313a046cb810ca9/mock-3.0.5-py2.py3-none-any.whl
Collecting sphinx (from -r /home/jenders/src/git-stacktrace/test-requirements.txt (line 7))
  Using cached https://pypi-pim.pinadmin.com/packages/76/42/a4465a0080e545cd152f7d3f16229d5e1300183fcb1067e4ec7e639b8605/Sphinx-2.2.0.tar.gz
    Complete output from command python setup.py egg_info:
    ERROR: Sphinx requires at least Python 3.5 to run.

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-8J4LSc/sphinx/
You are using pip version 8.1.2, however version 19.2.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

====================================================================================================================== log end ======================================================================================================================
ERROR: could not install deps [-r/home/jenders/src/git-stacktrace/test-requirements.txt]; v = InvocationError(u'/home/jenders/src/git-stacktrace/.tox/docs/bin/pip install -U -r/home/jenders/src/git-stacktrace/test-requirements.txt', 1)
______________________________________________________________________________________________________________________ summary ______________________________________________________________________________________________________________________
ERROR:   py27: could not install deps [-r/home/jenders/src/git-stacktrace/test-requirements.txt]; v = InvocationError(u'/home/jenders/src/git-stacktrace/.tox/py27/bin/pip install -U -r/home/jenders/src/git-stacktrace/test-requirements.txt', 1)
ERROR:  py36: InterpreterNotFound: python3.6
ERROR:   flake8: could not install deps [-r/home/jenders/src/git-stacktrace/test-requirements.txt]; v = InvocationError(u'/home/jenders/src/git-stacktrace/.tox/flake8/bin/pip install -U -r/home/jenders/src/git-stacktrace/test-requirements.txt', 1)
ERROR:   docs: could not install deps [-r/home/jenders/src/git-stacktrace/test-requirements.txt]; v = InvocationError(u'/home/jenders/src/git-stacktrace/.tox/docs/bin/pip install -U -r/home/jenders/src/git-stacktrace/test-requirements.txt', 1)

Unable to parse traceback

Input traceback

ValueError: invalid literal for int() with base 10: 'None'
  File "flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "flask_cors/extension.py", line 161, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "flask/_compat.py", line 33, in reraise
    raise value
  File "flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "<decorator-gen-39>", line 2, in ci
  File "geetest_client.py", line 209, in captcha_counter_decorator
    return func(*args, **kwargs)
  File "company.py", line 305, in ci
    company = get_company_info(company_id)
  File "company.py", line 129, in get_company_info
    return get_company_info_from_es(company_id) or get_company_info_from_element(company_id)
  File "company.py", line 144, in get_company_info_from_es
    annuals = choose_and_prettify_annual(company_id, result.get('extra', {}).get('类型', ''))
  File "company.py", line 174, in choose_and_prettify_annual
    result = prettify(annuals, is_llc=is_llc, show_all=show_all)
  File "prettify/annual.py", line 45, in prettify
    year = int(annual.get('year') or 0)

Error:

Traceback (most recent call last):
  File "/Users/messense/.local/bin/git-stacktrace", line 11, in <module>
    sys.exit(main())
  File "/Users/messense/.local/venvs/git-stacktrace/lib/python3.6/site-packages/git_stacktrace/cmd.py", line 45, in main
    traceback = api.parse_trace(blob)
  File "/Users/messense/.local/venvs/git-stacktrace/lib/python3.6/site-packages/git_stacktrace/parse_trace.py", line 195, in parse_trace
    raise ParseException("Unable to parse traceback")
git_stacktrace.parse_trace.ParseException: Unable to parse traceback

Unable to parse traceback

I'm trying to use this with a java stack trace, which I think is supported. However, I'm getting an error.

Traceback (most recent call last):
File "/usr/local/bin/git-stacktrace", line 10, in
sys.exit(main())
File "/Library/Python/3.8/site-packages/git_stacktrace/cmd.py", line 78, in main
traceback = api.parse_trace(blob)
File "/Library/Python/3.8/site-packages/git_stacktrace/parse_trace.py", line 254, in parse_trace
raise ParseException("Unable to parse traceback")
git_stacktrace.parse_trace.ParseException: Unable to parse traceback

This is my example stack trace copied from intelliJ
substituteVariables:1779, StringUtil (com.company.util)
substituteVariables:1857, StringUtil (com.company.util)
substituteVariables:1834, StringUtil (com.company.util)
substituteVariableWithNullMethodReturnsEmptyString:439, StringUtilTest (com.company.util)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.