8000 ENH: Lint checks for PR diffs by ganesh-k13 · Pull Request #18423 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

ENH: Lint checks for PR diffs #18423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Mar 7, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
MAINT: Added exception handling and docs
  • Loading branch information
ganesh-k13 committed Mar 7, 2021
commit 8e51b5b512a284cd580fdcdfff3cfbe556f013ac
16 changes: 13 additions & 3 deletions tools/linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys
import subprocess
from argparse import ArgumentParser
from git import Repo
from git import Repo, exc

BASE_BRANCH = 'master'
CONFIG = os.path.join(
Expand All @@ -16,8 +16,18 @@ def __init__(self, branch):
self.branch = branch
self.repo = Repo('.')

def get_branch_diff(self, uncommitted):
commit = self.repo.merge_base(BASE_BRANCH, self.branch)[0]
def get_branch_diff(self, uncommitted = False):
"""
Determine the first common ancestor commit.
Find diff between branch and FCA commit.
Note: if `uncommitted` is set, check only
uncommitted changes
"""
try:
commit = self.repo.merge_base(BASE_BRANCH, self.branch)[0]
except exc.GitCommandError:
print(f"Branch with name `{self.branch}` does not exist")
sys.exit(1)

if uncommitted:
diff = self.repo.git.diff(self.branch, '***.py')
Expand Down
0