bfg-ish: add some sanity checks on the specified repo

Signed-off-by: Elijah Newren <newren@gmail.com>
pull/222/merge
Elijah Newren 3 years ago
parent 06fa059744
commit dc012d277b

@ -174,6 +174,19 @@ class BFG_ish:
help=("file path for Git repository to clean"))
args = parser.parse_args()
# Sanity check on args.repo
if not os.path.isdir(args.repo):
raise SystemExit("Repo not found: {}".format(os.fsdecode(args.repo)))
dirname, basename = os.path.split(args.repo)
if not basename:
dirname, basename = os.path.split(dirname)
if not dirname:
dirname = b'.'
if basename == b".git":
raise SystemExit("For non-bare repos, please specify the toplevel directory ({}) for repo"
.format(os.fsdecode(dirname)))
return args
def convert_replace_text(self, filename):

Loading…
Cancel
Save