This repository has been 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
/
Remove-GitLabProjectRepositoryFile.ps1
62 lines (57 loc) · 1.81 KB
/
Remove-GitLabProjectRepositoryFile.ps1
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
function Remove-GitLabProjectRepositoryFile
{
<#
.SYNOPSIS
Delete existing file in repository
.DESCRIPTION
The Remove-GitLabProjectRepositoryFile function removes the specified file from the branch.
a commit message needs to be passed.
.EXAMPLE
Remove-GitLabProjectRepositoryFile -ProjectID 20 -BranchName master -FilePath 'Readme.md' -commit 'no readme needed'
---------------------------------------------------------------
Removes readme.md from branch master with commit 'no readme needed'
#>
[CmdletBinding(
SupportsShouldProcess=$true,
ConfirmImpact="High")]
[Alias()]
[OutputType()]
Param
(
# The ID of a project
[Parameter(HelpMessage = 'ProjectID',
Mandatory = $true)]
[Alias('ID')]
[int]$ProjectID,
# The name of branch
[Parameter(HelpMessage = 'Commit SHA or branch name',
Mandatory = $true)]
[Alias('branch_name')]
[string]$BranchName,
# The path of the file inside the projects repository.
[Parameter(Helpmessage = 'The path of the file',
Mandatory = $true)]
[alias('file_path')]
[String]$FilePath,
# Commit message
[Parameter(HelpMessage = 'Commit message',
Mandatory = $true)]
[alias('commit_message')]
[string]$CommitMessage,
# Specify Existing GitlabConnector
[Parameter(HelpMessage = 'Specify Existing GitlabConnector',
Mandatory = $false,
DontShow = $true)]
[psobject]$GitlabConnect = (Get-GitlabConnect)
)
$httpmethod = 'delete'
$apiurl = "/projects/$ProjectID/repository/files"
$parameters = @{
'file_path' = $FilePath
'branch_name' = $BranchName
'commit_message' = $CommitMessage
}
if($pscmdlet.ShouldProcess("$($BranchName):$FilePath","Remove")){
$GitlabConnect.callapi($apiurl,$httpmethod,$parameters)
}
}