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

Commit 627b3bb

Browse files
committed
Do not attach inline when the file does not exist in the revision
1 parent cb81cfd commit 627b3bb

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/main/kotlin/io/nthienan/phdiff/PhabricatorDifferentialPostJob.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ class PhabricatorDifferentialPostJob(
6262
log.debug("Comment $ic has been published")
6363
} catch (e: ConduitException) {
6464
if (e.message.equals("Requested file doesn't exist in this revision.")) {
65-
val message = "Unmodified file " + filePath + " on line " + i.line() + "\n\n" + ic
66-
differentialClient.postComment(diff.revisionId, message)
65+
val message = "Unmodified file $filePath on line ${i.line()}\n\n $ic"
66+
differentialClient.postComment(diff.revisionId, message, false)
6767
} else {
6868
log.error(e.message, e)
6969
}

src/main/kotlin/io/nthienan/phdiff/conduit/DifferentialClient.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,19 @@ class DifferentialClient(val conduitClient: ConduitClient) {
1818
* @param message the content of the comment
1919
* @param silent whether or not to trigger an email
2020
* @param action phabricator comment action, e.g. 'resign', 'reject', 'none'
21+
* @param attachInlines whether attach inline comments or not
2122
* @return the Conduit API response
2223
* @throws IOException if there is a network error talking to Conduit
2324
* @throws ConduitException if any error is experienced talking to Conduit
2425
*/
2526
@Throws(IOException::class, ConduitException::class)
26-
fun postComment(revisionID: String, message: String, silent: Boolean, action: String): JSONObject {
27-
var params = JSONObject()
27+
fun postComment(revisionID: String, message: String, silent: Boolean, action: String, attachInlines: Boolean = true): JSONObject {
28+
val params = JSONObject()
2829
.put("revision_id", revisionID)
2930
.put("action", action)
3031
.put("message", message)
3132
.put("silent", silent)
32-
.put("attach_inlines", true)
33+
.put("attach_inlines", attachInlines)
3334
return conduitClient.perform("differential.createcomment", params)
3435
}
3536

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

7577
/**

0 commit comments

Comments
 (0)