private String getLastLine(String input) { String output = input; int breakLength = Text.DELIMITER.length(); // remove last line break if exist int lastIndexOfLineBreak = output.lastIndexOf(Text.DELIMITER); if (lastIndexOfLineBreak != -1 && lastIndexOfLineBreak == output.length() - breakLength) output = output.substring(0, output.length() - breakLength); // get the last line lastIndexOfLineBreak = output.lastIndexOf(Text.DELIMITER); return lastIndexOfLineBreak == -1 ? output : output.substring(lastIndexOfLineBreak + breakLength, output.length()); }
private void saveOriginalChangeId() { int changeIdOffset = findOffsetOfChangeIdLine(previousCommitMessage); if (changeIdOffset > 0) { int endOfChangeId = findNextEOL(changeIdOffset, previousCommitMessage); if (endOfChangeId < 0) endOfChangeId = previousCommitMessage.length(); int sha1Offset = changeIdOffset + Text.DELIMITER.length() + "Change-Id: I".length(); // $NON-NLS-1$ try { originalChangeId = ObjectId.fromString(previousCommitMessage.substring(sha1Offset, endOfChangeId)); } catch (IllegalArgumentException e) { originalChangeId = null; } } else originalChangeId = null; }
private void refreshSignedOffBy() { String curText = commitText.getText(); if (signedOff) // add signed off line commitText.setText(signOff(curText)); else { // remove signed off line String s = getSignedOff(); if (s != null) { curText = replaceSignOff(curText, s, EMPTY_STRING); if (curText.endsWith(Text.DELIMITER + Text.DELIMITER)) curText = curText.substring(0, curText.length() - Text.DELIMITER.length()); commitText.setText(curText); } } }