Skip to content
This repository has been archived by the owner on Jun 12, 2022. It is now read-only.

Commit

Permalink
Do not attach inline when the file does not exist in the revision
Browse files Browse the repository at this point in the history
  • Loading branch information
nthienan committed Oct 5, 2017
1 parent cb81cfd commit 627b3bb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ class PhabricatorDifferentialPostJob(
log.debug("Comment $ic has been published")
} catch (e: ConduitException) {
if (e.message.equals("Requested file doesn't exist in this revision.")) {
val message = "Unmodified file " + filePath + " on line " + i.line() + "\n\n" + ic
differentialClient.postComment(diff.revisionId, message)
val message = "Unmodified file $filePath on line ${i.line()}\n\n $ic"
differentialClient.postComment(diff.revisionId, message, false)
} else {
log.error(e.message, e)
}
Expand Down
12 changes: 7 additions & 5 deletions src/main/kotlin/io/nthienan/phdiff/conduit/DifferentialClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,19 @@ class DifferentialClient(val conduitClient: ConduitClient) {
* @param message the content of the comment
* @param silent whether or not to trigger an email
* @param action phabricator comment action, e.g. 'resign', 'reject', 'none'
* @param attachInlines whether attach inline comments or not
* @return the Conduit API response
* @throws IOException if there is a network error talking to Conduit
* @throws ConduitException if any error is experienced talking to Conduit
*/
@Throws(IOException::class, ConduitException::class)
fun postComment(revisionID: String, message: String, silent: Boolean, action: String): JSONObject {
var params = JSONObject()
fun postComment(revisionID: String, message: String, silent: Boolean, action: String, attachInlines: Boolean = true): JSONObject {
val params = JSONObject()
.put("revision_id", revisionID)
.put("action", action)
.put("message", message)
.put("silent", silent)
.put("attach_inlines", true)
.put("attach_inlines", attachInlines)
return conduitClient.perform("differential.createcomment", params)
}

Expand Down Expand Up @@ -64,12 +65,13 @@ class DifferentialClient(val conduitClient: ConduitClient) {
* Post a comment on the differential
* @param revisionID the revision ID (e.g. "D1234" without the "D")
* @param message the string message to post
* @param attachInlines whether attach inline comments or not
* @return the Conduit API response
* @throws ConduitException if any error is experienced talking to Conduit
*/
@Throws(ConduitException::class)
fun postComment(revisionID: String, message: String): JSONObject {
return postComment(revisionID, message, false, "none")
fun postComment(revisionID: String, message: String, attachInlines: Boolean = true): JSONObject {
return postComment(revisionID, message, false, "none", attachInlines)
}

/**
Expand Down

0 comments on commit 627b3bb

Please sign in to comment.