Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-shell
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-shell
Commits
4656cd71
Commit
4656cd71
authored
Sep 13, 2018
by
Ash McKenzie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Print message to $stderr for custom action
parent
58acc2b6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
111 additions
and
0 deletions
+111
-0
lib/action/custom.rb
lib/action/custom.rb
+6
-0
spec/action/custom_spec.rb
spec/action/custom_spec.rb
+6
-0
spec/vcr_cassettes/custom-action-ok-with-message.yml
spec/vcr_cassettes/custom-action-ok-with-message.yml
+99
-0
No files found.
lib/action/custom.rb
View file @
4656cd71
...
...
@@ -54,6 +54,8 @@ module Action
raise
UnsuccessfulError
,
'Response was not valid JSON'
end
inform_client
(
body
[
'message'
])
if
body
[
'message'
]
print_flush
(
body
[
'result'
])
# In the context of the git push sequence of events, it's necessary to read
...
...
@@ -94,6 +96,10 @@ module Action
$stdout
.
flush
end
def
inform_client
(
str
)
$stderr
.
puts
(
str
)
end
def
validate!
validate_payload!
validate_data!
...
...
spec/action/custom_spec.rb
View file @
4656cd71
...
...
@@ -52,6 +52,12 @@ describe Action::Custom do
allow
(
$stdout
).
to
receive
(
:print
).
with
(
'push-result'
)
end
it
'prints a message to $stderr'
do
VCR
.
use_cassette
(
"custom-action-ok-with-message"
)
do
expect
{
subject
.
execute
}.
to
output
(
/NOTE: Message here/
).
to_stderr
end
end
it
'returns an instance of Net::HTTPCreated'
do
VCR
.
use_cassette
(
"custom-action-ok"
)
do
expect
(
subject
.
execute
).
to
be_instance_of
(
Net
::
HTTPCreated
)
...
...
spec/vcr_cassettes/custom-action-ok-with-message.yml
0 → 100644
View file @
4656cd71
---
http_interactions
:
-
request
:
method
:
post
uri
:
http://localhost:3000/api/v4/fake/info_refs
body
:
encoding
:
UTF-8
string
:
'
{"data":{"gl_username":"user1","primary_repo":"http://localhost:3001/user1/repo1.git","gl_id":"key-1"},"output":"","secret_token":"0a3938d9d95d807e94d937af3a4fbbea"}'
headers
:
Content-Type
:
-
application/json
Accept-Encoding
:
-
gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Accept
:
-
"
*/*"
User-Agent
:
-
Ruby
Host
:
-
localhost
response
:
status
:
code
:
200
message
:
OK
headers
:
Date
:
-
Fri, 20 Jul 2018 06:18:58 GMT
Connection
:
-
close
X-Frame-Options
:
-
SAMEORIGIN
X-Content-Type-Options
:
-
nosniff
Content-Type
:
-
application/json
Content-Length
:
-
'
172'
Vary
:
-
Origin
Etag
:
-
W/"7d01e1e3dbcbe7cca9607461352f8244"
Cache-Control
:
-
max-age=0, private, must-revalidate
X-Request-Id
:
-
03afa234-b6be-49ab-9392-4aa35c5dee25
X-Runtime
:
-
'
1.436040'
body
:
encoding
:
UTF-8
string
:
'
{"result":"aW5mb19yZWZzLXJlc3VsdA==\n",
"message":"NOTE:
Message
here"}'
http_version
:
recorded_at
:
Fri, 20 Jul 2018 06:18:58 GMT
-
request
:
method
:
post
uri
:
http://localhost:3000/api/v4/fake/push
body
:
encoding
:
UTF-8
string
:
'
{"data":{"gl_username":"user1","primary_repo":"http://localhost:3001/user1/repo1.git","gl_id":"key-1"},"output":"info_refs-result","secret_token":"0a3938d9d95d807e94d937af3a4fbbea"}'
headers
:
Content-Type
:
-
application/json
Accept-Encoding
:
-
gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Accept
:
-
"
*/*"
User-Agent
:
-
Ruby
Host
:
-
localhost
response
:
status
:
code
:
201
message
:
Created
headers
:
Date
:
-
Fri, 20 Jul 2018 06:19:08 GMT
Connection
:
-
close
X-Frame-Options
:
-
SAMEORIGIN
X-Content-Type-Options
:
-
nosniff
Content-Type
:
-
application/json
Content-Length
:
-
'
13'
Vary
:
-
Origin
Cache-Control
:
-
no-cache
X-Request-Id
:
-
0c6894ac-7f8e-4cdb-871f-4cb64d3731ca
X-Runtime
:
-
'
0.786754'
body
:
encoding
:
UTF-8
string
:
'
{"result":"cHVzaC1yZXN1bHQ=\n"}'
http_version
:
recorded_at
:
Fri, 20 Jul 2018 06:19:08 GMT
recorded_with
:
VCR 2.4.0
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