summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateParserTest.java1
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificate.java17
2 files changed, 16 insertions, 2 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateParserTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateParserTest.java
index 824766e165..644b9017ce 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateParserTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateParserTest.java
@@ -215,6 +215,7 @@ public class PushCertificateParserTest {
cmd.getNewId().name());
assertEquals(concatPacketLines(INPUT, 0, 6), cert.toText());
+ assertEquals(concatPacketLines(INPUT, 0, 17), cert.toTextWithSignature());
String signature = concatPacketLines(INPUT, 6, 17);
assertTrue(signature.startsWith(PushCertificateParser.BEGIN_SIGNATURE));
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificate.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificate.java
index 413b02b1c8..dbdf93b964 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificate.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificate.java
@@ -203,6 +203,19 @@ public class PushCertificate {
* @since 4.1
*/
public String toText() {
+ return toStringBuilder().toString();
+ }
+
+ /**
+ * @return original text payload plus signature; the final output will be
+ * valid as input to {@link PushCertificateParser#fromString(String)}.
+ * @since 4.1
+ */
+ public String toTextWithSignature() {
+ return toStringBuilder().append(signature).toString();
+ }
+
+ private StringBuilder toStringBuilder() {
StringBuilder sb = new StringBuilder()
.append(VERSION).append(' ').append(version).append('\n')
.append(PUSHER).append(' ').append(getPusher())
@@ -215,7 +228,7 @@ public class PushCertificate {
.append(' ').append(cmd.getNewId().name())
.append(' ').append(cmd.getRefName()).append('\n');
}
- return sb.toString();
+ return sb;
}
@Override
@@ -256,6 +269,6 @@ public class PushCertificate {
@Override
public String toString() {
return getClass().getSimpleName() + '['
- + toText() + signature + ']';
+ + toTextWithSignature() + ']';
}
}