Changeset 294367 in webkit


Ignore:
Timestamp:
May 17, 2022 5:20:12 PM (2 years ago)
Author:
Jonathan Bedard
Message:

[git-webkit] Use --date=unix in log commands
https://bugs.webkit.org/show_bug.cgi?id=240537

Reviewed by Stephanie Lewis.

Override any local configuration for git log's date format,
use a simpler date format.

  • Tools/Scripts/libraries/webkitscmpy/setup.py: Bump version.
  • Tools/Scripts/libraries/webkitscmpy/webkitscmpy/init.py: Ditto.
  • Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py:

(Git.Cache.populate): Use --date=unix.
(Git.commit): Ditto.
(Git._args_from_content): Parse --date=unix.
(Git.commits): Use --date=unix.

  • Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py:
  • Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py:

(TestGit.test_log):

Canonical link: https://commits.webkit.org/250668@main

Location:
trunk/Tools/Scripts/libraries/webkitscmpy
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/Scripts/libraries/webkitscmpy/setup.py

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

    r294038 r294367  
    4747    )
    4848
    49 version = Version(4, 14, 1)
     49version = Version(4, 14, 2)
    5050
    5151AutoInstall.register(Package('fasteners', Version(0, 15, 0)))
  • trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py

    r293557 r294367  
    3131import time
    3232
    33 from datetime import datetime, timedelta
    3433from collections import defaultdict
    3534
     
    131130                self._last_populated[branch] = time.time()
    132131                log = subprocess.Popen(
    133                     [self.repo.executable(), 'log', branch, '--no-decorate'],
     132                    [self.repo.executable(), 'log', branch, '--no-decorate', '--date=unix'],
    134133                    cwd=self.repo.root_path,
    135134                    stdout=subprocess.PIPE,
     
    556555        default_branch = self.default_branch
    557556        parsed_branch_point = None
    558         log_format = ['-1', '--no-decorate'] if include_log else ['-1', '--no-decorate', '--format=short']
     557        log_format = ['-1', '--no-decorate', '--date=unix'] if include_log else ['-1', '--no-decorate', '--date=unix', '--format=short']
    559558
    560559        # Determine the `git log` output and branch for a given identifier
     
    713712                author = Contributor.from_scm_log(line.lstrip(), self.contributors)
    714713            elif split[0] == 'CommitDate':
    715                 tz_diff = line.split(' ')[-1]
    716                 date = datetime.strptime(split[1].lstrip()[:-len(tz_diff)], '%a %b %d %H:%M:%S %Y ')
    717                 date += timedelta(
    718                     hours=int(tz_diff[1:3]),
    719                     minutes=int(tz_diff[3:5]),
    720                 ) * (1 if tz_diff[0] == '-' else -1)
    721                 timestamp = int(calendar.timegm(date.timetuple())) - time.timezone
     714                timestamp = int(line.split(' ')[-1])
    722715
    723716        message = ''
     
    739732            log = None
    740733            log = subprocess.Popen(
    741                 [self.executable(), 'log', '--format=fuller', '--no-decorate', '{}...{}'.format(end.hash, begin.hash)],
     734                [self.executable(), 'log', '--format=fuller', '--no-decorate', '--date=unix', '{}...{}'.format(end.hash, begin.hash)],
    742735                cwd=self.root_path,
    743736                stdout=subprocess.PIPE,
  • trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py

    r293831 r294367  
    272272                ) if self.find(args[2]) else mocks.ProcessCompletion(returncode=128)
    273273            ), mocks.Subprocess.Route(
    274                 self.executable, 'log', re.compile(r'.+'), '-1', '--no-decorate',
     274                self.executable, 'log', re.compile(r'.+'), '-1', '--no-decorate', '--date=unix',
    275275                cwd=self.path,
    276276                generator=lambda *args, **kwargs: mocks.ProcessCompletion(
     
    285285                            author=self.find(args[2]).author.name,
    286286                            email=self.find(args[2]).author.email,
    287                             date=datetime.utcfromtimestamp(self.find(args[2]).timestamp + time.timezone).strftime('%a %b %d %H:%M:%S %Y +0000'),
     287                            date=self.find(args[2]).timestamp,
    288288                            log='\n'.join([
    289289                                    ('    ' + line) if line else '' for line in self.find(args[2]).message.splitlines()
     
    297297                ) if self.find(args[2]) else mocks.ProcessCompletion(returncode=128),
    298298            ), mocks.Subprocess.Route(
    299                 self.executable, 'log', '--format=fuller', '--no-decorate', re.compile(r'.+\.\.\..+'),
     299                self.executable, 'log', '--format=fuller', '--no-decorate', '--date=unix', re.compile(r'.+\.\.\..+'),
    300300                cwd=self.path,
    301301                generator=lambda *args, **kwargs: mocks.ProcessCompletion(
     
    311311                            author=commit.author.name,
    312312                            email=commit.author.email,
    313                             date=datetime.utcfromtimestamp(commit.timestamp + time.timezone).strftime('%a %b %d %H:%M:%S %Y +0000'),
     313                            date=commit.timestamp,
    314314                            log='\n'.join([
    315315                                ('    ' + line) if line else '' for line in commit.message.splitlines()
     
    320320                                   commit.revision,
    321321                            )] if git_svn else []),
    322                         )) for commit in list(self.commits_in_range(args[4].split('...')[-1], args[4].split('...')[0]))[:-1]
     322                        )) for commit in list(self.commits_in_range(args[5].split('...')[-1], args[5].split('...')[0]))[:-1]
    323323                    ])
    324324                )
     
    336336                            author=commit.author.name,
    337337                            email=commit.author.email,
    338                             date=datetime.utcfromtimestamp(commit.timestamp + time.timezone).strftime('%a %b %d %H:%M:%S %Y +0000'),
     338                            date=commit.timestamp if '--date=unix' in args else datetime.utcfromtimestamp(commit.timestamp + time.timezone).strftime('%a %b %d %H:%M:%S %Y +0000'),
    339339                            log='\n'.join([
    340340                                ('    ' + line) if line else '' for line in commit.message.splitlines()
  • trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py

    r292844 r294367  
    318318            self.assertEqual(
    319319                run([
    320                     local.Git.executable(), 'log', '--format=fuller', '--no-decorate', 'remotes/origin/main...1abe25b4',
     320                    local.Git.executable(), 'log', '--format=fuller', '--no-decorate', '--date=unix', 'remotes/origin/main...1abe25b4',
    321321                ], cwd=self.path, capture_output=True, encoding='utf-8').stdout,
    322322                '''commit d8bce26fa65c6fc8f39c17927abb77f69fab82fc
     
    338338    git-svn-id: https://svn.example.org/repository/repository/trunk@8 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    339339'''.format(
    340                 time_a=datetime.utcfromtimestamp(1601668000 + time.timezone).strftime('%a %b %d %H:%M:%S %Y +0000'),
    341                 time_b=datetime.utcfromtimestamp(1601663000 + time.timezone).strftime('%a %b %d %H:%M:%S %Y +0000'),
     340                time_a=1601668000,
     341                time_b=1601663000,
    342342            ))
    343343
     
    346346            self.assertEqual(
    347347                run([
    348                     local.Git.executable(), 'log', '--format=fuller', '--no-decorate', 'branch-b...main',
     348                    local.Git.executable(), 'log', '--format=fuller', '--no-decorate', '--date=unix', 'branch-b...main',
    349349                ], cwd=self.path, capture_output=True, encoding='utf-8').stdout,
    350350                '''commit 790725a6d79e28db2ecdde29548d2262c0bd059d
     
    368368    git-svn-id: https://svn.example.org/repository/repository/trunk@5 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    369369'''.format(
    370                 time_a=datetime.utcfromtimestamp(1601667000 + time.timezone).strftime('%a %b %d %H:%M:%S %Y +0000'),
    371                 time_b=datetime.utcfromtimestamp(1601664000 + time.timezone).strftime('%a %b %d %H:%M:%S %Y +0000'),
    372                 time_c=datetime.utcfromtimestamp(1601662000 + time.timezone).strftime('%a %b %d %H:%M:%S %Y +0000'),
     370                time_a=1601667000,
     371                time_b=1601664000,
     372                time_c=1601662000,
    373373            ))
    374374
Note: See TracChangeset for help on using the changeset viewer.