Exemple #1
0
def update_revision_description(transactions, commit, revision):
    # Appends differential.revision.edit transaction(s) to `transactions` if
    # updating the commit title and/or summary is required.

    if commit["title"] != revision["fields"]["title"]:
        transactions.append(dict(type="title", value=commit["title"]))

    # The Phabricator API will refuse the new summary value if we include the
    # "Differential Revision:" keyword in the summary body.
    local_body = strip_differential_revision(commit["body"]).strip()
    remote_body = strip_differential_revision(revision["fields"]["summary"]).strip()
    if local_body != remote_body:
        transactions.append(dict(type="summary", value=local_body))
Exemple #2
0
def amend_revision_url(body, new_url):
    """Append or replace the Differential Revision URL in a commit body."""
    body = strip_differential_revision(body)
    if body:
        body += "\n"
    body += "\nDifferential Revision: %s" % new_url
    return body
 def test_strip_differential_revision_from_commit_body(self):
     self.assertEqual("", helpers.strip_differential_revision("\n\n"))
     self.assertEqual(
         "",
         helpers.strip_differential_revision(
             "\nDifferential Revision: http://phabricator.test/D123"
         ),
     )
     self.assertEqual(
         "",
         helpers.strip_differential_revision(
             "Differential Revision: http://phabricator.test/D123"
         ),
     )
     self.assertEqual(
         "title",
         helpers.strip_differential_revision(
             "title\nDifferential Revision: http://phabricator.test/D123"
         ),
     )
     self.assertEqual(
         "title",
         helpers.strip_differential_revision(
             "title\n\nDifferential Revision: http://phabricator.test/D123"
         ),
     )
     self.assertEqual(
         "title\n\nsummary",
         helpers.strip_differential_revision(
             "title\n\n"
             "summary\n\n"
             "Differential Revision: http://phabricator.test/D123"
         ),
     )