Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
go-gitlab
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
go-gitlab
Commits
6cdaa84f
Commit
6cdaa84f
authored
Jun 30, 2019
by
Sae-ngow Wasin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update changed request, add test and test result.
parent
11c87810
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
6 deletions
+41
-6
commits.go
commits.go
+6
-6
commits_test.go
commits_test.go
+26
-0
get_signature.json
testdata/get_signature.json
+9
-0
No files found.
commits.go
View file @
6cdaa84f
...
...
@@ -552,7 +552,7 @@ func (s *CommitsService) RevertCommit(pid interface{}, sha string, opt *RevertCo
//
// GitLab API docs: https://docs.gitlab.com/ee/api/commits.html#get-gpg-signature-of-a-commit
type
GPGSubKey
struct
{
KeyID
sql
.
NullInt64
sql
.
NullInt64
}
// GPGSignature represents a Gitlab commit's GPG Signature.
...
...
@@ -575,19 +575,19 @@ func (s *CommitsService) GetGPGSiganature(pid interface{}, sha string, options .
if
err
!=
nil
{
return
nil
,
nil
,
err
}
u
:=
fmt
.
Sprintf
(
"projects/%s/repository/commits/%s/signature"
,
pathEscape
(
project
),
sha
)
url
:=
fmt
.
Sprintf
(
"projects/%s/repository/commits/%s/signature"
,
pathEscape
(
project
),
sha
)
req
,
err
:=
s
.
client
.
NewRequest
(
"GET"
,
url
,
nil
,
options
)
req
,
err
:=
s
.
client
.
NewRequest
(
"GET"
,
u
,
nil
,
options
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
var
signature
*
GPGSignature
resp
,
err
:=
s
.
client
.
Do
(
req
,
&
sig
nature
)
sig
:=
new
(
GPGSignature
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
&
sig
)
if
err
!=
nil
{
return
nil
,
resp
,
err
}
return
sig
nature
,
resp
,
err
return
sig
,
resp
,
err
}
commits_test.go
View file @
6cdaa84f
...
...
@@ -174,3 +174,29 @@ func TestRevertCommit_WithOptions(t *testing.T) {
assert
.
Equal
(
t
,
want
,
commit
)
}
func
TestGetGPGSignature
(
t
*
testing
.
T
)
{
mux
,
server
,
client
:=
setup
()
defer
teardown
(
server
)
mux
.
HandleFunc
(
"/api/v4/projects/1/repository/commits/b0b3a907f41409829b307a28b82fdbd552ee5a27/signature"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
testMethod
(
t
,
r
,
"GET"
)
mustWriteHTTPResponse
(
t
,
w
,
"testdata/get_signature.json"
)
})
sig
,
resp
,
err
:=
client
.
Commits
.
GetGPGSiganature
(
"1"
,
"b0b3a907f41409829b307a28b82fdbd552ee5a27"
,
nil
)
if
err
!=
nil
{
t
.
Fatalf
(
"Commits.GetGPGSignature returned error: %v, response: %v"
,
err
,
resp
)
}
want
:=
&
GPGSignature
{
KeyID
:
7977
,
KeyPrimaryKeyID
:
"627C5F589F467F17"
,
KeyUserName
:
"Dmitriy Zaporozhets"
,
KeyUserEmail
:
"dmitriy.zaporozhets@gmail.com"
,
VerificationStatus
:
"verified"
,
KeySubkeyID
:
nil
,
}
assert
.
Equal
(
t
,
want
,
sig
)
}
testdata/get_signature.json
0 → 100644
View file @
6cdaa84f
{
"gpg_key_id"
:
7977
,
"gpg_key_primary_keyid"
:
"627C5F589F467F17"
,
"gpg_key_user_name"
:
"Dmitriy Zaporozhets"
,
"gpg_key_user_email"
:
"dmitriy.zaporozhets@gmail.com"
,
"verification_status"
:
"verified"
,
"gpg_key_subkey_id"
:
null
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment