Set-GitRemotes: имя repo из remote URL, не из имени папки.
This commit is contained in:
@@ -29,9 +29,26 @@ function Test-GitRepo {
|
||||
}
|
||||
}
|
||||
|
||||
function Get-RepoNameFromRemoteUrl {
|
||||
param([string]$Url)
|
||||
if ($Url -match '/([^/]+?)(?:\.git)?/?$') {
|
||||
return $Matches[1]
|
||||
}
|
||||
return $null
|
||||
}
|
||||
|
||||
function Get-RepoName {
|
||||
param([string]$Name)
|
||||
if ($Name) { return $Name }
|
||||
|
||||
foreach ($remote in @('kalinamall', 'home', 'github', 'origin')) {
|
||||
$url = git remote get-url $remote 2>$null
|
||||
if ($url) {
|
||||
$fromUrl = Get-RepoNameFromRemoteUrl -Url $url.Trim()
|
||||
if ($fromUrl) { return $fromUrl }
|
||||
}
|
||||
}
|
||||
|
||||
return (Split-Path -Leaf (git rev-parse --show-toplevel))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user