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 pathNew-GitLabProjectRepositoryCommitComment.ps1
More file actions
66 lines (58 loc) · 1.99 KB
/
Copy pathNew-GitLabProjectRepositoryCommitComment.ps1
File metadata and controls
66 lines (58 loc) · 1.99 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
function New-GitLabProjectRepositoryCommitComment
{
<#
.SYNOPSIS
Add a comment to a commit.
.DESCRIPTION
the New-GitLabProjectRepositoryCommitComment function adds a comment to a repositories commit.
Return the comment with -PassThru
.EXAMPLE
New-GitLabProjectRepositoryCommitComment -ProjectID 20 -SHA 5a411e1 -Note 'has braking changes'
---------------------------------------------------------------
adds the comment 'has braking changes' to commit 5a411e1 in project 20.
.EXAMPLE
New-GitLabProjectRepositoryCommitComment -ProjectID 20 -SHA 5a411e1 -Note 'has braking changes' -PassThru
---------------------------------------------------------------
Adds the comment 'has braking changes' to commit 5a411e1 in project 20.
Returns the created comment.
#>
[CmdletBinding(defaultParameterSetName = 'ToFullCommit')]
[Alias()]
[OutputType()]
Param
(
#The ID of a project
[Parameter(HelpMessage = 'The ID of a project',
Mandatory = $true)]
[Alias('ID')]
[int]$ProjectID,
#The commit hash or name of a repository branch or tag
[Parameter(HelpMessage = 'Commit Reference(hash|branchname|tagname)',
Mandatory = $true)]
[String]$SHA,
#The text of the comment
[Parameter(HelpMessage = 'The text of the comment',
Mandatory = $true)]
[string]$Note,
# Specify Existing GitlabConnector
[Parameter(HelpMessage = 'Specify Existing GitlabConnector',
Mandatory = $false,
DontShow = $true)]
[psobject]$GitlabConnect = (Get-GitlabConnect),
# Return the created comment
[Parameter(HelpMessage = 'Passthru the created object',
Mandatory = $false)]
[switch]$PassThru
)
$httpmethod = 'post'
$apiurl = "projects/$ProjectID/repository/commits/$sha/comments"
$parameters = @{}
$body = @{
note = $Note
}
$NewCommitComment = $GitlabConnect.callapi($apiurl,$httpmethod,$parameters,$body)
if($PassThru)
{
return $NewCommitComment
}
}