From 7f50f58e46eed6453478e6ac5006ac4d34d466a1 Mon Sep 17 00:00:00 2001 From: Tobias Vilhelmsen Date: Wed, 10 Jul 2019 22:05:21 +0200 Subject: [PATCH 1/3] Adds branch --- PSGitLab/Public/Branches/Get-GitLabBranch.ps1 | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 PSGitLab/Public/Branches/Get-GitLabBranch.ps1 diff --git a/PSGitLab/Public/Branches/Get-GitLabBranch.ps1 b/PSGitLab/Public/Branches/Get-GitLabBranch.ps1 new file mode 100644 index 0000000..6d66cbc --- /dev/null +++ b/PSGitLab/Public/Branches/Get-GitLabBranch.ps1 @@ -0,0 +1,31 @@ +Function Get-GitLabBranch { + [cmdletbinding(DefaultParameterSetName = 'All')] + [OutputType('GitLab.Branch')] + param( + + [Parameter(Mandatory = $true)] + [string]$ProjectId, + + [Parameter(ParameterSetName = 'All')] + [switch]$All, + + [Parameter(ParameterSetName = 'Branch')] + [string]$Branch, + + [Parameter(ParameterSetName = 'Search')] + [string]$Search + ) + + $Request = @{ + URI = '' + Method = 'GET' + } + + switch ( $PSCmdlet.ParameterSetName) { + 'Branch' { $Request.URI = "/projects/{0}/repository/branches/{1}" -f $ProjectId, $Branch } + 'All' { $Request.URI = "/projects/{0}/repository/branches" -f $ProjectId } + 'Search' { $Request.URI = "/projects/{0}/repository/branches?search={1}" -f $ProjectId, $Search } + } + + QueryGitLabAPI -Request $Request -ObjectType 'GitLab.Branch' +} \ No newline at end of file From 6de6f00dc0a4b98e59d23832cefdd7868c0d93ad Mon Sep 17 00:00:00 2001 From: Tobias Vilhelmsen Date: Sun, 14 Jul 2019 22:32:22 +0200 Subject: [PATCH 2/3] Adds get-gitlabbranch to functionstoexport --- PSGitLab/PSGitLab.psd1 | 1 + 1 file changed, 1 insertion(+) diff --git a/PSGitLab/PSGitLab.psd1 b/PSGitLab/PSGitLab.psd1 index 0377978..c512d20 100644 --- a/PSGitLab/PSGitLab.psd1 +++ b/PSGitLab/PSGitLab.psd1 @@ -71,6 +71,7 @@ FunctionsToExport = @( 'Block-GitLabUser', 'Close-GitLabMergeRequest', 'Close-GitLabMilestone', + 'Get-GitLabBranch', 'Get-GitLabCommitStats', 'Get-GitLabGroup', 'Get-GitLabIssue', From c9809995ce8f4c257f11a17b1065bfe61fced707 Mon Sep 17 00:00:00 2001 From: Tobias Vilhelmsen Date: Sun, 14 Jul 2019 22:57:26 +0200 Subject: [PATCH 3/3] Adds help --- PSGitLab/Public/Branches/Get-GitLabBranch.ps1 | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/PSGitLab/Public/Branches/Get-GitLabBranch.ps1 b/PSGitLab/Public/Branches/Get-GitLabBranch.ps1 index 6d66cbc..dee9adb 100644 --- a/PSGitLab/Public/Branches/Get-GitLabBranch.ps1 +++ b/PSGitLab/Public/Branches/Get-GitLabBranch.ps1 @@ -1,17 +1,33 @@ +<# +.Synopsis + Get-GitLabBranch - Find branches on a specific project +.DESCRIPTION + Function for finding branches on a specific project. Can return all branches, specific branch, or search for branches by name. +.EXAMPLE + Get-GitLabBranch -ProjectId 64 -All +.EXAMPLE + Get-GitLabBranch -ProjectId 64 -Branch Master +.EXAMPLE + Get-GitLabBranch -ProjectId 64 -Search Test +#> Function Get-GitLabBranch { [cmdletbinding(DefaultParameterSetName = 'All')] [OutputType('GitLab.Branch')] param( - + + #Id of the project [Parameter(Mandatory = $true)] [string]$ProjectId, + #Will return all branches associated to project [Parameter(ParameterSetName = 'All')] [switch]$All, + #Specify branch name to return specific branch [Parameter(ParameterSetName = 'Branch')] [string]$Branch, + #Search for branch [Parameter(ParameterSetName = 'Search')] [string]$Search )