Giter Club home page Giter Club logo

git_guardrails's People

Contributors

mike-north avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

git_guardrails's Issues

Add testing for windows in CI

Something about running

make pex

fails when trying to run against windows-latest in CI. There's no indication that actually using this tool in windows is a problem, but without fixing this, windows developers will have some significant problems contributing to the project

Add Python 3.6 testing in CI

Something something fails in CI when we try to run

make pex

using Python 3.6. I have disabled this part of the python compatibility testing in #1, since there's no indication that running the resulting code will cause issues in this version of python.

As this version of python is supported until end of CY2021, we should test this in CI to protect against regression

Workaround until we address this

Use Python 3.7 or newer

[BUG] "default branch" detection fails when both `main` and `master` origin refs are present

Describe the bug
This CLI crashes when a git repo has both a main and master branch. It can't make a clear determination about where pull requests are likely to target

To Reproduce
Clone a repo that has both a main and master branch

Expected behavior
At the very least, a graceful failure (perhaps even asking users which branch they aim to target)

Screenshots

|===|===|===|== Git Guardrails ==|===|===|===|
Traceback (most recent call last):
  File "/Users/mnorth/.pex/installed_wheels/59d63e79b53503f5403220d3159d8e409c46e107/GitPython-3.1.17-py3-none-any.whl/git/util.py", line 977, in __getitem__
    return getattr(self, index)
  File "/Users/mnorth/.pex/installed_wheels/59d63e79b53503f5403220d3159d8e409c46e107/GitPython-3.1.17-py3-none-any.whl/git/util.py", line 968, in __getattr__
    return list.__getattribute__(self, attr)
AttributeError: 'IterableList' object has no attribute 'master'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/mnorth/git_guardrails/.bootstrap/pex/pex.py", line 484, in execute
  File "/Users/mnorth/git_guardrails/.bootstrap/pex/pex.py", line 401, in _wrap_coverage
  File "/Users/mnorth/git_guardrails/.bootstrap/pex/pex.py", line 432, in _wrap_profiling
  File "/Users/mnorth/git_guardrails/.bootstrap/pex/pex.py", line 540, in _execute
  File "/Users/mnorth/git_guardrails/.bootstrap/pex/pex.py", line 656, in execute_entry
  File "/Users/mnorth/git_guardrails/.bootstrap/pex/pex.py", line 688, in execute_pkg_resources
  File "/Users/mnorth/.pex/installed_wheels/84c3bec5425741213732a0a74b22a81e728b774a/click-8.0.0-py3-none-any.whl/click/core.py", line 1134, in __call__
    return self.main(*args, **kwargs)
  File "/Users/mnorth/.pex/installed_wheels/84c3bec5425741213732a0a74b22a81e728b774a/click-8.0.0-py3-none-any.whl/click/core.py", line 1059, in main
    rv = self.invoke(ctx)
  File "/Users/mnorth/.pex/installed_wheels/84c3bec5425741213732a0a74b22a81e728b774a/click-8.0.0-py3-none-any.whl/click/core.py", line 1665, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/mnorth/.pex/installed_wheels/84c3bec5425741213732a0a74b22a81e728b774a/click-8.0.0-py3-none-any.whl/click/core.py", line 1401, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/mnorth/.pex/installed_wheels/84c3bec5425741213732a0a74b22a81e728b774a/click-8.0.0-py3-none-any.whl/click/core.py", line 767, in invoke
    return __callback(*args, **kwargs)
  File "/Users/mnorth/.pex/installed_wheels/100cb598db7089e3acf7e20ec75ef1cff4c2cb54/git_guardrails-0.1b1-py3-none-any.whl/git_guardrails/coroutine.py", line 10, in wrapper
    return loop.run_until_complete(coroutine_f(*args, **kwargs))
  File "/export/apps/python/3.7/lib/python3.7/asyncio/base_events.py", line 587, in run_until_complete
    return future.result()
  File "/Users/mnorth/.pex/installed_wheels/100cb598db7089e3acf7e20ec75ef1cff4c2cb54/git_guardrails-0.1b1-py3-none-any.whl/git_guardrails/command_line.py", line 76, in validate
    await do_validate(cli, opts)
  File "/Users/mnorth/.pex/installed_wheels/100cb598db7089e3acf7e20ec75ef1cff4c2cb54/git_guardrails-0.1b1-py3-none-any.whl/git_guardrails/validate/__init__.py", line 194, in do_validate
    (active_branch, default_branch) = await validate_branches_and_merge_bases(cli=cli, repo=repo, opts=opts)
  File "/Users/mnorth/.pex/installed_wheels/100cb598db7089e3acf7e20ec75ef1cff4c2cb54/git_guardrails-0.1b1-py3-none-any.whl/git_guardrails/validate/__init__.py", line 111, in validate_branches_and_merge_bases
    default_branch = get_branch_information(repo, await get_default_git_branch(repo))  # default branch
  File "/Users/mnorth/.pex/installed_wheels/100cb598db7089e3acf7e20ec75ef1cff4c2cb54/git_guardrails-0.1b1-py3-none-any.whl/git_guardrails/validate/__init__.py", line 48, in get_branch_information
    branch_head: Head = repo.heads[branch_name]
  File "/Users/mnorth/.pex/installed_wheels/59d63e79b53503f5403220d3159d8e409c46e107/GitPython-3.1.17-py3-none-any.whl/git/util.py", line 979, in __getitem__
    raise IndexError("No item found with id %r" % (self._prefix + index)) from e
IndexError: No item found with id 'master'

Desktop (please complete the following information):

  • OS: [e.g. macOS 10.15.1] * macos 11.4
  • Python version: [e.g., 3.7.10 -- findable via python3 --version] 3.7.10
  • git_guardrails version [e.g. 0.1.1] 0.1b1 (Beta)

Bugs are much more actionable if you can provide a small git repo (e.g., a zipped-up workspace) where the problem occurs.

[BUG] User-friendly error needed for tracked branch that has been deleted

Describe the bug
Currently git_guardrails prints a non-actionable error message when operating on a git branch that claims to track a remote branch, but that remote branch is not found

To Reproduce
Steps to reproduce the behavior:

  1. Create a PR branch with a few commits on it
  2. Push the branch to your origin remote
  3. Delete the branch from the remote by running git push origin :<branch name>
  4. Run git_guardrails validate

Expected behavior
The user should be presented with an actionable error message, saying that the "upstream" branch cannot be found

Screenshots

|===|===|===|== Git Guardrails ==|===|===|===|
determined that local branch docs tracks upstream branch docs on remote origin
Traceback (most recent call last):
  File "/home/linuxbrew/.linuxbrew/bin/git_guardrails", line 33, in <module>
    sys.exit(load_entry_point('git-guardrails', 'console_scripts', 'git_guardrails')())
  File "/home/linuxbrew/.linuxbrew/opt/[email protected]/lib/python3.7/site-packages/click/core.py", line 1134, in __call__
    return self.main(*args, **kwargs)
  File "/home/linuxbrew/.linuxbrew/opt/[email protected]/lib/python3.7/site-packages/click/core.py", line 1059, in main
    rv = self.invoke(ctx)
  File "/home/linuxbrew/.linuxbrew/opt/[email protected]/lib/python3.7/site-packages/click/core.py", line 1665, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/linuxbrew/.linuxbrew/opt/[email protected]/lib/python3.7/site-packages/click/core.py", line 1401, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/linuxbrew/.linuxbrew/opt/[email protected]/lib/python3.7/site-packages/click/core.py", line 767, in invoke
    return __callback(*args, **kwargs)
  File "/home/mnorth/Development/oss/git_guardrails/src/git_guardrails/coroutine.py", line 10, in wrapper
    return loop.run_until_complete(coroutine_f(*args, **kwargs))
  File "/home/linuxbrew/.linuxbrew/opt/[email protected]/lib/python3.7/asyncio/base_events.py", line 587, in run_until_complete
    return future.result()
  File "/home/mnorth/Development/oss/git_guardrails/src/git_guardrails/command_line.py", line 76, in validate
    await do_validate(cli, opts)
  File "/home/mnorth/Development/oss/git_guardrails/src/git_guardrails/validate/__init__.py", line 195, in do_validate
    (latest_remote_sha, active_branch_tracked_ref) = analyze_review_branch_tracking_situation(cli, repo, active_branch)
  File "/home/mnorth/Development/oss/git_guardrails/src/git_guardrails/validate/__init__.py", line 148, in analyze_review_branch_tracking_situation
    ref_types=["heads"])
  File "/home/mnorth/Development/oss/git_guardrails/src/git_guardrails/git_utils.py", line 44, in git_ls_remote
    [latest_sha, _] = ls_remote_output.split()
ValueError: not enough values to unpack (expected 2, got 0)
make: *** [Makefile:26: run-validate] Error 1

Desktop (please complete the following information):

  • OS: [e.g. macOS 10.15.1] Windows 10 (WSL2)
  • Python version: [e.g., 3.7.10 -- findable via python3 --version] 3.7.10
  • git_guardrails version [e.g. 0.1.1] 0.1b1

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.