summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGanesh Kathiresan <ganesh3597@gmail.com>2021-02-16 14:40:51 +0530
committerGanesh Kathiresan <ganesh3597@gmail.com>2021-03-07 11:18:23 +0530
commit8e51b5b512a284cd580fdcdfff3cfbe556f013ac (patch)
tree517fb762254f061d517c50211866d323961ec999
parentf43ba6df89974d050f944987711366c5f0268f60 (diff)
downloadnumpy-8e51b5b512a284cd580fdcdfff3cfbe556f013ac.tar.gz
MAINT: Added exception handling and docs
-rw-r--r--tools/linter.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/tools/linter.py b/tools/linter.py
index 509e199d8..bd54097e3 100644
--- a/tools/linter.py
+++ b/tools/linter.py
@@ -2,7 +2,7 @@ import os
import sys
import subprocess
from argparse import ArgumentParser
-from git import Repo
+from git import Repo, exc
BASE_BRANCH = 'master'
CONFIG = os.path.join(
@@ -16,8 +16,18 @@ class DiffLinter:
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')