Skip to content

Commit 9456127

Browse files
Add: create pull request to origin repository from local over git protocol
1 parent 5f5a01b commit 9456127

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

Posh-Github.psm1

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function GetRemotes
1313
if ($matches -ne $null) { $matches.Clear() }
1414
$gitRemotes = git remote -v show 2> $null
1515

16-
$pattern = '^(.*)?\t.*github.com\/(.*)\/(.*) \((fetch|push)\)'
16+
$pattern = '^(.*)?\t.*github.com[:\/](.*)\/(.*) \((fetch|push)\)'
1717
$gitRemotes |
1818
Select-String -Pattern $pattern -AllMatches |
1919
% {
@@ -380,13 +380,19 @@ function New-GitHubPullRequest
380380
{
381381
#try to sniff out the repo based on 'upstream'
382382
$remotes = GetRemotes
383-
if (!($remotes.upstream))
383+
384+
$remote = $remotes.upstream
385+
if (!($remote))
384386
{
385-
throw "No remote named 'upstream' defined, so cannot determine where to send pull"
387+
$remote = $remotes.origin
386388
}
389+
if (!($remote))
390+
{
391+
throw "No remote named 'upstream' or 'origin' defined, so cannot determine where to send pull"
392+
}
387393

388-
$Owner = $remotes.upstream.owner
389-
$Repository = $remotes.upstream.repository
394+
$Owner = $remote.owner
395+
$Repository = $remote.repository
390396
}
391397
elseif ([string]::IsNullOrEmpty($Owner) -or [string]::IsNullOrEmpty($Repository))
392398
{
@@ -396,7 +402,7 @@ function New-GitHubPullRequest
396402
if ([string]::IsNullOrEmpty($Head))
397403
{
398404
$localUser = git remote -v show |
399-
? { $_ -match 'origin\t.*github.com\/(.*)\/.* \((fetch|push)\)' } |
405+
? { $_ -match 'origin\t.*github.com[:\/](.*)\/.* \((fetch|push)\)' } |
400406
% { $matches[1] } |
401407
Select -First 1
402408

0 commit comments

Comments
 (0)