Skip to content

Commit dc012d2

Browse files
committed
bfg-ish: add some sanity checks on the specified repo
Signed-off-by: Elijah Newren <[email protected]>
1 parent 06fa059 commit dc012d2

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

contrib/filter-repo-demos/bfg-ish

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,19 @@ class BFG_ish:
174174
help=("file path for Git repository to clean"))
175175

176176
args = parser.parse_args()
177+
178+
# Sanity check on args.repo
179+
if not os.path.isdir(args.repo):
180+
raise SystemExit("Repo not found: {}".format(os.fsdecode(args.repo)))
181+
dirname, basename = os.path.split(args.repo)
182+
if not basename:
183+
dirname, basename = os.path.split(dirname)
184+
if not dirname:
185+
dirname = b'.'
186+
if basename == b".git":
187+
raise SystemExit("For non-bare repos, please specify the toplevel directory ({}) for repo"
188+
.format(os.fsdecode(dirname)))
189+
177190
return args
178191

179192
def convert_replace_text(self, filename):

0 commit comments

Comments
 (0)