< Back

Invoke-GitOpen

Mon Jan 13, 2020 8:30 pm

NAME Invoke-GitOpen



SYNOPSIS

Opens up a browser window to the git repository's remote





SYNTAX

Invoke-GitOpen [-PR] [[-CustomRepoTypes] <Array>] [<CommonParameters>]





DESCRIPTION

When executed from in a git repository, will open up a web browser to the

repository's remote configuration. This allows for easy and seamless transition

between local work and remote work - managing pull requests, issues, and general

code management stuff.





PARAMETERS

-PR [<SwitchParameter>]

Switch to open up the remote config pull request screen



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-CustomRepoTypes <Array>

This array allows for some customization. In a lot of enterprise settings, a

custom URL is used for the source control management system. An array of

repo types that can be used to find & replace values in the .gitconfig.



Each object in the array should include these properties:

Name: The name of the custom config

Type: "BitBucket" or "Github"

Find: String to look for in the .gitconfig to determine whether repo is this type

Replace: *OPTIONAL* when finding the string, optional ability to replace

UrlBase: The start of the URL for your git config. Example: "https://dev.azure.com"

BrowseUrlFormat: The format of the browse URL. This varies by source control type

PRUrlFormat: The format of the PR URL. This varies by source control type



Example:

@{

Name = 'BitBucketCustom'

Type = 'BitBucket'

Find = 'ssh://git@git.companyname.com:7999'

Replace = 'https://git.companyname.com'

UrlBase = 'https://git.companyname.com'

BrowseUrlFormat = '$urlBase/projects/$projectName/repos/$repoName/browse?at=refs%2Fheads%2F$branchName'

PRUrlFormat = '$urlBase/projects/$projectName/repos/$repoName/pull-requests'

}



Required? false

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



-------------------------- EXAMPLE 1 --------------------------



PS C:\\SomeGitRepo>Invoke-GitOpen



Will open up a web browser to the "SomeGitRepo" remote.









-------------------------- EXAMPLE 2 --------------------------



PS C:\\SomeGitRepo>$companyRepoType = @{



Name = 'BitBucketCustom'

Type = 'BitBucket'

Find = 'ssh://git@git.companyname.com:7999'

Replace = 'https://git.companyname.com'

UrlBase = 'https://git.companyname.com'

BrowseUrlFormat = '$urlBase/projects/$projectName/repos/$repoName/browse?at=refs%2Fheads%2F$branchName'

PRUrlFormat = '$urlBase/projects/$projectName/repos/$repoName/pull-requests'

}

PS C:\\SomeGitRepo> Invoke-GitOpen -CustomRepoTypes @($companyRepoType)



My company uses SSH for git operations. This configuration will find the

ssh configuration for my company repositories and then replace that ssh remote

configuration with the https remote URL.











RELATED LINKS