Changeset 284926 in webkit


Ignore:
Timestamp:
Oct 27, 2021, 10:11:30 AM (4 years ago)
Author:
Jonathan Bedard
Message:

[webkitscmpy] Ensure empty line before canonicalization
https://bugs.webkit.org/show_bug.cgi?id=232103
<rdar://problem/84521382>

Reviewed by Stephanie Lewis.

  • Scripts/libraries/webkitscmpy/setup.py: Bump version.
  • Scripts/libraries/webkitscmpy/webkitscmpy/init.py: Ditto.
  • Scripts/libraries/webkitscmpy/webkitscmpy/program/canonicalize/message.py:

(main): Handle empty lines around identifier links, add empty line before identifier links.

  • Scripts/libraries/webkitscmpy/webkitscmpy/test/canonicalize_unittest.py:

(TestCanonicalize.test_formated_identifier):
(TestCanonicalize.test_existing_identifier):
(TestCanonicalize.test_git_svn):
(TestCanonicalize.test_git_svn_existing):
(TestCanonicalize.test_branch_commits):
(TestCanonicalize.test_number):

Location:
trunk/Tools
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r284922 r284926  
     12021-10-27  Jonathan Bedard  <jbedard@apple.com>
     2
     3        [webkitscmpy] Ensure empty line before canonicalization
     4        https://bugs.webkit.org/show_bug.cgi?id=232103
     5        <rdar://problem/84521382>
     6
     7        Reviewed by Stephanie Lewis.
     8
     9        * Scripts/libraries/webkitscmpy/setup.py: Bump version.
     10        * Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto.
     11        * Scripts/libraries/webkitscmpy/webkitscmpy/program/canonicalize/message.py:
     12        (main): Handle empty lines around identifier links, add empty line before identifier links.
     13        * Scripts/libraries/webkitscmpy/webkitscmpy/test/canonicalize_unittest.py:
     14        (TestCanonicalize.test_formated_identifier):
     15        (TestCanonicalize.test_existing_identifier):
     16        (TestCanonicalize.test_git_svn):
     17        (TestCanonicalize.test_git_svn_existing):
     18        (TestCanonicalize.test_branch_commits):
     19        (TestCanonicalize.test_number):
     20
    1212021-10-27  Alexey Proskuryakov  <ap@apple.com>
    222
  • trunk/Tools/Scripts/libraries/webkitscmpy/setup.py

    r284892 r284926  
    3030setup(
    3131    name='webkitscmpy',
    32     version='2.2.16',
     32    version='2.2.17',
    3333    description='Library designed to interact with git and svn repositories.',
    3434    long_description=readme(),
  • trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py

    r284892 r284926  
    4747    )
    4848
    49 version = Version(2, 2, 16)
     49version = Version(2, 2, 17)
    5050
    5151AutoInstall.register(Package('fasteners', Version(0, 15, 0)))
  • trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/canonicalize/message.py

    r272378 r284926  
    5757        identifier_index -= 1
    5858
     59    # We're trying to cover cases where there is a space between link and git-svn-id:
     60    #     <commit message content>
     61    #
     62    #     Canonical link: ...
     63    #     git-svn-id: ...
     64    # OR
     65    #     <commit message content>
     66    #     Canonical link: ...
     67    #
     68    #     git-svn-id: ...
    5969    if identifier_index and lines[identifier_index - 1].startswith(identifier_template.format('').split(':')[0]):
    6070        lines[identifier_index - 1] = identifier_template.format(commit)
     71        identifier_index = identifier_index - 2
     72    elif identifier_index and lines[identifier_index - 2].startswith(identifier_template.format('').split(':')[0]):
     73        del lines[identifier_index - 2]
     74        lines.insert(identifier_index - 1, identifier_template.format(commit))
     75        identifier_index = identifier_index - 2
    6176    else:
    6277        lines.insert(identifier_index, identifier_template.format(commit))
     78
     79    if lines[identifier_index]:
     80        lines.insert(identifier_index, '')
    6381
    6482    for line in lines:
  • trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/canonicalize_unittest.py

    r279347 r284926  
    7575            commit = local.Git(self.path).commit(branch=mock.default_branch)
    7676            self.assertEqual(commit.author, contirbutors['zdobersek@igalia.com'])
    77             self.assertEqual(commit.message, 'New commit\nCanonical link: https://commits.webkit.org/6@main')
     77            self.assertEqual(commit.message, 'New commit\n\nCanonical link: https://commits.webkit.org/6@main')
    7878
    7979        self.assertEqual(
     
    9595                identifier=mock.commits[mock.default_branch][-1].identifier + 1,
    9696                timestamp=1601668000,
    97                 message='New commit\nIdentifier: {}@{}'.format(
     97                message='New commit\n\nIdentifier: {}@{}'.format(
    9898                    mock.commits[mock.default_branch][-1].identifier + 1,
    9999                    mock.default_branch,
     
    109109            commit = local.Git(self.path).commit(branch=mock.default_branch)
    110110            self.assertEqual(commit.author, contirbutors['jbedard@apple.com'])
    111             self.assertEqual(commit.message, 'New commit\nIdentifier: 6@main')
     111            self.assertEqual(commit.message, 'New commit\n\nIdentifier: 6@main')
    112112
    113113        self.assertEqual(
     
    143143            self.assertEqual(
    144144                commit.message,
    145                 'New commit\n'
     145                'New commit\n\n'
    146146                'Identifier: 6@main\n'
    147147                'git-svn-id: https://svn.example.org/repository/repository/trunk@9 268f45cc-cd09-0410-ab3c-d52691b4dbfc',
     
    159159        )
    160160
     161    def test_git_svn_existing(self):
     162        with OutputCapture() as captured, mocks.local.Git(self.path, git_svn=True) as mock, mocks.local.Svn(), MockTime:
     163            contirbutors = Contributor.Mapping()
     164            contirbutors.create('Jonathan Bedard', 'jbedard@apple.com')
     165
     166            mock.commits[mock.default_branch].append(Commit(
     167                hash='766609276fe201e7ce2c69994e113d979d2148ac',
     168                branch=mock.default_branch,
     169                author=Contributor('jbedard@apple.com', emails=['jbedard@apple.com']),
     170                identifier=mock.commits[mock.default_branch][-1].identifier + 1,
     171                timestamp=1601668000,
     172                revision=9,
     173                message='New commit\nIdentifier: 6@main\n\n',
     174            ))
     175
     176            self.assertEqual(0, program.main(
     177                args=('canonicalize', '-vv'),
     178                path=self.path,
     179                contributors=contirbutors,
     180            ))
     181
     182            commit = local.Git(self.path).commit(branch=mock.default_branch)
     183            self.assertEqual(commit.author, contirbutors['jbedard@apple.com'])
     184            self.assertEqual(
     185                commit.message,
     186                'New commit\n\n'
     187                'Identifier: 6@main\n'
     188                'git-svn-id: https://svn.example.org/repository/repository/trunk@9 268f45cc-cd09-0410-ab3c-d52691b4dbfc',
     189            )
     190
     191        self.assertEqual(
     192            captured.stdout.getvalue(),
     193            'Rewrite 766609276fe201e7ce2c69994e113d979d2148ac (1/1) (--- seconds passed, remaining --- predicted)\n'
     194            'Overwriting 766609276fe201e7ce2c69994e113d979d2148ac\n'
     195            '    GIT_AUTHOR_NAME=Jonathan Bedard\n'
     196            '    GIT_AUTHOR_EMAIL=jbedard@apple.com\n'
     197            '    GIT_COMMITTER_NAME=Jonathan Bedard\n'
     198            '    GIT_COMMITTER_EMAIL=jbedard@apple.com\n'
     199            '1 commit successfully canonicalized!\n',
     200        )
     201
    161202    def test_branch_commits(self):
    162203        with OutputCapture() as captured, mocks.local.Git(self.path) as mock, mocks.local.Svn(), MockTime:
     
    192233            commit_a = local.Git(self.path).commit(branch='branch-a~1')
    193234            self.assertEqual(commit_a.author, contirbutors['jbedard@apple.com'])
    194             self.assertEqual(commit_a.message, 'New commit 1\nIdentifier: 2.3@branch-a')
     235            self.assertEqual(commit_a.message, 'New commit 1\n\nIdentifier: 2.3@branch-a')
    195236
    196237            commit_b = local.Git(self.path).commit(branch='branch-a')
    197238            self.assertEqual(commit_b.author, contirbutors['jbedard@apple.com'])
    198             self.assertEqual(commit_b.message, 'New commit 2\nIdentifier: 2.4@branch-a')
     239            self.assertEqual(commit_b.message, 'New commit 2\n\nIdentifier: 2.4@branch-a')
    199240
    200241        self.assertEqual(
     
    216257            ))
    217258
    218             self.assertEqual(local.Git(self.path).commit(identifier='5@main').message, 'Patch Series\nIdentifier: 5@main')
    219             self.assertEqual(local.Git(self.path).commit(identifier='4@main').message, '8th commit\nIdentifier: 4@main')
    220             self.assertEqual(local.Git(self.path).commit(identifier='3@main').message, '4th commit\nIdentifier: 3@main')
     259            self.assertEqual(local.Git(self.path).commit(identifier='5@main').message, 'Patch Series\n\nIdentifier: 5@main')
     260            self.assertEqual(local.Git(self.path).commit(identifier='4@main').message, '8th commit\n\nIdentifier: 4@main')
     261            self.assertEqual(local.Git(self.path).commit(identifier='3@main').message, '4th commit\n\nIdentifier: 3@main')
    221262
    222263        self.assertEqual(
Note: See TracChangeset for help on using the changeset viewer.