Esempio n. 1
0
 private void insertChangeId(ObjectId treeId) throws IOException {
   ObjectId firstParentId = null;
   if (!parents.isEmpty()) firstParentId = parents.get(0);
   ObjectId changeId =
       ChangeIdUtil.computeChangeId(treeId, firstParentId, author, committer, message);
   message = ChangeIdUtil.insertId(message, changeId);
   if (changeId != null)
     message =
         message.replaceAll(
             "\nChange-Id: I" + ObjectId.zeroId().getName() + "\n",
             "\nChange-Id: I" + changeId.getName() + "\n");
 }
 private void refreshChangeIdText() {
   if (createChangeId) {
     // ChangeIdUtil uses \n line endings
     String text = commitText.getText().replaceAll(Text.DELIMITER, "\n"); // $NON-NLS-1$
     String changedText =
         ChangeIdUtil.insertId(
             text, originalChangeId != null ? originalChangeId : ObjectId.zeroId(), true);
     if (!text.equals(changedText)) {
       changedText = changedText.replaceAll("\n", Text.DELIMITER); // $NON-NLS-1$
       commitText.setText(changedText);
     }
   } else {
     String text = commitText.getText();
     int changeIdOffset = findOffsetOfChangeIdLine(text);
     if (changeIdOffset > 0) {
       String cleanedText;
       int endOfChangeId = findNextEOL(changeIdOffset, text);
       if (endOfChangeId == -1) cleanedText = text.substring(0, changeIdOffset);
       else cleanedText = text.substring(0, changeIdOffset) + text.substring(endOfChangeId);
       commitText.setText(cleanedText);
     }
   }
 }