fix: prevent double clone for clone command with URL

- Differentiate logic when a URL is used for the clone command.
- Parse URL to get identifiers without cloning the repository.
- This avoids an implicit clone before the explicit one.
- Retain original `get_repo` behavior for other commands.
This commit is contained in:
Mahmoud-Emad
2025-08-13 13:07:30 +03:00
parent 55f0621983
commit f7ed2ea31e

View File

@@ -66,10 +66,19 @@ pub fn (mut gs GitStructure) do(args_ ReposActionsArgs) !string {
if !(args.repo == '' && args.account == '' && args.provider == '' && args.filter == '') {
return error('when specify url cannot specify repo, account, profider or filter')
}
mut r0 := gs.get_repo(url: args.url)!
args.repo = r0.name
args.account = r0.account
args.provider = r0.provider
if args.cmd.trim_space().to_lower() == 'clone' {
// Do NOT call get_repo for clone: it would clone implicitly and then clone again below
// Only derive identifiers from the URL so later logging/printing can use them
mut gl := gs.gitlocation_from_url(args.url)!
args.repo = gl.name
args.account = gl.account
args.provider = gl.provider
} else {
mut r0 := gs.get_repo(url: args.url)!
args.repo = r0.name
args.account = r0.account
args.provider = r0.provider
}
}
args.cmd = args.cmd.trim_space().to_lower()