-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(2437): Support read-only SCM [4] #41
Conversation
index.js
Outdated
|
||
return { comments: prComments.body }; | ||
} catch (err) { | ||
logger.warn('Failed to fetch PR comments: ', prComments.body.message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If an exception occurs, prComments is undefined and prComments.body.message will cause error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be a better log would be with repoId and prNum
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
index.js
Outdated
* Edit a particular comment in the PR | ||
* @async editPrComment | ||
* @param {Integer} commentId The id of the particular comment to be edited | ||
* @param {Object} scmInfo The information regarding SCM like repo, owner |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove scmInfo (not used) and add repoId
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also add prNum to param definition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
@@ -790,29 +871,57 @@ class GitlabScm extends Scm { | |||
* @param {String} config.token The token used to authenticate to the SCM | |||
* @return {Promise} | |||
*/ | |||
async _addPrComment({ comment, prNum, scmUri, token }) { | |||
async _addPrComment({ comment, prNum, scmUri }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update jsdoc
} | ||
}); | ||
|
||
return pullRequestComment; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return pullRequestComment && pullRequestComment.body
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change is causing some issues with tests, so leaving as is
index.js
Outdated
commentId: `${pullRequestComment.body.id}`, | ||
createTime: `${pullRequestComment.body.created_at}`, | ||
username: pullRequestComment.body.author.username |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update after Line 855 and check for undefined.
const pullRequestComment = await this.breaker.runCommand({ | ||
json: true, | ||
method: 'POST', | ||
auth: { | ||
bearer: this.config.commentUserToken | ||
}, | ||
url: `${this.config.gitlabProtocol}://${this.config.gitlabHost}/api/v4` + | ||
`/projects/${repoId}/merge_requests/${prNum}/notes`, | ||
qs: { | ||
body: comment | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it is convenient, refactor the api calls to a single func with url as param
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will update at a different time
Context
Should support read-only SCM.
Objective
This PR:
readOnly
config in SCM optionscloneType
forgetCheckoutCommand()
addPRComment()
and other PR comment methodsReferences
Related screwdriver-cd/screwdriver#2437
License
I confirm that this contribution is made under the terms of the license found in the root directory of this repository's source tree and that I have the authority necessary to make this contribution on behalf of its copyright owner.