This repository was archived by the owner on Sep 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGet-GitLabProjectRepositoryTree.ps1
More file actions
70 lines (62 loc) · 2.36 KB
/
Copy pathGet-GitLabProjectRepositoryTree.ps1
File metadata and controls
70 lines (62 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
function Get-GitLabProjectRepositoryTree
{
<#
.SYNOPSIS
Get a list of Repository files and directories in a project.
.DESCRIPTION
Get a list of Repository files and directories in a project.
By deafult only shows files and folders in the root of the project for the default branch.
-Path can be passed to dig down into the directory structure.
to specify a different branch of commit -ReferenceName can be used.
.EXAMPLE
Get-GitLabProjectRepositoryTree -ProjectID 20
---------------------------------------------------------------
retrieves all files for project 20.
Returns all the files and folders for the default branch in the repository root.
.EXAMPLE
Get-GitLabProjectRepositoryTree -ProjectID 20 -Path bin/
---------------------------------------------------------------
retrieves all files for project 20 in folder bin/.
Returns all the files and folders for the default branch in bin/.
.EXAMPLE
Get-GitLabProjectRepositoryTree -ProjectID 20 -ReferenceName staging
---------------------------------------------------------------
retrieves all files for project 20 in branch staging.
Returns all the files and folders for the branch staging.
#>
[CmdletBinding()]
[Alias('Get-GitLabRepository')]
[OutputType()]
Param
(
# The ID of the project
[Parameter(Mandatory = $true, HelpMessage = 'The ID of a project')]
[Alias('ID')]
[String]$ProjectID,
#The path inside repository. Used to get contend of subdirectories
[Parameter(Helpmessage = 'path inside repository',
Mandatory = $false)]
[String]$Path,
#The name of a repository branch or tag or if not given the default branch
[Parameter(Helpmessage = 'Name of a repository branch or tag',
Mandatory = $false)]
[Alias('ref_name','RefName')]
[String]$ReferenceName,
[Parameter(HelpMessage = 'Specify Existing GitlabConnector',
Mandatory = $false,
DontShow = $true)]
[psobject]$GitlabConnect = (Get-GitlabConnect)
)
$httpmethod = 'get'
$apiurl = "projects/$([System.Web.HttpUtility]::UrlEncode($projectId))/repository/tree"
$Parameters = @{}
if($Path)
{
$Parameters.path = $Path
}
if($ReferenceName)
{
$Parameters.'ref_name' = $ReferenceName
}
$GitlabConnect.callapi($apiurl,$httpmethod,$Parameters)
}