Bug 219982

Summary: [webkitscmpy] Add command to canonicalize unpushed commits
Product: WebKit Reporter: Jonathan Bedard <jbedard>
Component: Tools / TestsAssignee: Jonathan Bedard <jbedard>
Status: RESOLVED FIXED    
Severity: Normal CC: aakash_jain, ap, dewei_zhu, slewis, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=219988
https://bugs.webkit.org/show_bug.cgi?id=219989
https://bugs.webkit.org/show_bug.cgi?id=219992
https://bugs.webkit.org/show_bug.cgi?id=220369
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch for landing none

Jonathan Bedard
Reported 2020-12-17 08:36:27 PST
We need to add a command to modify authorship and insert identifiers into commit before they are pushed to the remote.
Attachments
Patch (39.50 KB, patch)
2020-12-17 09:56 PST, Jonathan Bedard
no flags
Patch (37.45 KB, patch)
2020-12-17 15:51 PST, Jonathan Bedard
no flags
Patch (37.48 KB, patch)
2020-12-18 07:02 PST, Jonathan Bedard
no flags
Patch (37.50 KB, patch)
2020-12-18 13:43 PST, Jonathan Bedard
no flags
Patch (37.50 KB, patch)
2020-12-18 14:00 PST, Jonathan Bedard
no flags
Patch (39.12 KB, patch)
2020-12-18 16:21 PST, Jonathan Bedard
no flags
Patch (39.09 KB, patch)
2021-01-05 13:11 PST, Jonathan Bedard
no flags
Patch (2.20 KB, patch)
2021-01-05 22:06 PST, Jonathan Bedard
no flags
Patch for landing (2.69 KB, patch)
2021-01-06 08:00 PST, Jonathan Bedard
no flags
Radar WebKit Bug Importer
Comment 1 2020-12-17 08:36:42 PST
Jonathan Bedard
Comment 2 2020-12-17 09:56:49 PST
Jonathan Bedard
Comment 3 2020-12-17 10:16:08 PST
Comment on attachment 416434 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=416434&action=review > Tools/Scripts/libraries/webkitscmpy/webkitscmpy/canonicalize/message.py:60 > + lines[identifier_index - 1] = 'Identifier: {}'.format(commit) I know Alexey has an opinion on this bit in that he thinks it should be a URL, which would look like: <https://scm.webkit.org/1234@main>
Jonathan Bedard
Comment 4 2020-12-17 10:16:49 PST
(In reply to Jonathan Bedard from comment #3) > Comment on attachment 416434 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=416434&action=review > > > Tools/Scripts/libraries/webkitscmpy/webkitscmpy/canonicalize/message.py:60 > > + lines[identifier_index - 1] = 'Identifier: {}'.format(commit) > > I know Alexey has an opinion on this bit in that he thinks it should be a > URL, which would look like: > <https://scm.webkit.org/1234@main> Note: This service does not yet exist, so this URL is dead.
Jonathan Bedard
Comment 5 2020-12-17 15:51:15 PST
Jonathan Bedard
Comment 6 2020-12-18 07:02:28 PST
Jonathan Bedard
Comment 7 2020-12-18 13:43:14 PST
Alexey Proskuryakov
Comment 8 2020-12-18 13:47:54 PST
Comment on attachment 416542 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=416542&action=review > Tools/Scripts/libraries/webkitscmpy/webkitscmpy/canonicalize/message.py:62 > + lines.insert(identifier_index, 'Identifier: {}'.format(identifier_template.format(commit))) I continue to think that we want a descriptive name here that gives at least a hint for how it's expected to be used by people, e.g. "Canonical link".
Alexey Proskuryakov
Comment 9 2020-12-18 13:48:33 PST
Comment on attachment 416542 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=416542&action=review >> Tools/Scripts/libraries/webkitscmpy/webkitscmpy/canonicalize/message.py:62 >> + lines.insert(identifier_index, 'Identifier: {}'.format(identifier_template.format(commit))) > > I continue to think that we want a descriptive name here that gives at least a hint for how it's expected to be used by people, e.g. "Canonical link". Also, on a purely nitpicking level, the URL is not the identifier, only the last part of it is.
Jonathan Bedard
Comment 10 2020-12-18 14:00:30 PST
Jonathan Bedard
Comment 11 2020-12-18 16:21:30 PST
Jonathan Bedard
Comment 12 2021-01-05 13:11:51 PST
dewei_zhu
Comment 13 2021-01-05 14:26:47 PST
Comment on attachment 417028 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=417028&action=review > Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program.py:186 > + from webkitscmpy.canonicalize import Canonicalize There was a version of patch that splits the commands into different files, but we decided to keep them in a single file since there were too few commands/code to split them. I see the deferred import is to avoid circular import. Do you think it's time to consider re-split commands? > Tools/Scripts/libraries/webkitscmpy/webkitscmpy/canonicalize/committer.py:50 > + REPOSITORY_PATH = os.environ.get('OLDPWD') I do see GIT_* are set somewhere, but I don't see we set OLDPWD anywhere. How do we guarantee this since OLDPWD might be different based on PWD history.
Jonathan Bedard
Comment 14 2021-01-05 14:44:23 PST
Comment on attachment 417028 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=417028&action=review >> Tools/Scripts/libraries/webkitscmpy/webkitscmpy/canonicalize/committer.py:50 >> + REPOSITORY_PATH = os.environ.get('OLDPWD') > > I do see GIT_* are set somewhere, but I don't see we set OLDPWD anywhere. How do we guarantee this since OLDPWD might be different based on PWD history. The GIT_* variables are both read and written, OLDPWD is only read. The bash code you see is actually reading the values of the GIT_* variables printed out by this script and exporting that to git filter-branch. Seems like git filter-branch always sets OLDPWD, although I'm not entirely certain why (seems likely to be something about git's underlying bash-y nature)
Jonathan Bedard
Comment 15 2021-01-05 15:06:37 PST
Comment on attachment 417028 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=417028&action=review >> Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program.py:186 >> + from webkitscmpy.canonicalize import Canonicalize > > There was a version of patch that splits the commands into different files, but we decided to keep them in a single file since there were too few commands/code to split them. > I see the deferred import is to avoid circular import. Do you think it's time to consider re-split commands? I do, but I think that should be a stand-alone patch. No reason to make this one more complicated than it already is
dewei_zhu
Comment 16 2021-01-05 15:42:28 PST
Comment on attachment 417028 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=417028&action=review >>> Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program.py:186 >>> + from webkitscmpy.canonicalize import Canonicalize >> >> There was a version of patch that splits the commands into different files, but we decided to keep them in a single file since there were too few commands/code to split them. >> I see the deferred import is to avoid circular import. Do you think it's time to consider re-split commands? > > I do, but I think that should be a stand-alone patch. No reason to make this one more complicated than it already is Sure. >>> Tools/Scripts/libraries/webkitscmpy/webkitscmpy/canonicalize/committer.py:50 >>> + REPOSITORY_PATH = os.environ.get('OLDPWD') >> >> I do see GIT_* are set somewhere, but I don't see we set OLDPWD anywhere. How do we guarantee this since OLDPWD might be different based on PWD history. > > The GIT_* variables are both read and written, OLDPWD is only read. The bash code you see is actually reading the values of the GIT_* variables printed out by this script and exporting that to git filter-branch. > > Seems like git filter-branch always sets OLDPWD, although I'm not entirely certain why (seems likely to be something about git's underlying bash-y nature) Got it.
dewei_zhu
Comment 17 2021-01-05 15:52:43 PST
r=me. Discussed with Jonathan in person, `git filter-branch` will set OLDPWD to the repo. Another approach Jonathan mentioned is to use 'GIT_DIR'. I'm OK with both approach.
EWS
Comment 18 2021-01-05 16:36:17 PST
Committed r271182: <https://trac.webkit.org/changeset/271182> All reviewed patches have been landed. Closing bug and clearing flags on attachment 417028 [details].
Jonathan Bedard
Comment 19 2021-01-05 22:06:05 PST
Reopening to attach new patch.
Jonathan Bedard
Comment 20 2021-01-05 22:06:06 PST
Aakash Jain
Comment 21 2021-01-06 07:05:19 PST
> Tools/Scripts/libraries/webkitscmpy/webkitscmpy/canonicalize/__init__.py:62 > if not repository.path: Should repository.path be changed here as well?
Aakash Jain
Comment 22 2021-01-06 07:05:27 PST
Comment on attachment 417065 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=417065&action=review > Tools/Scripts/libraries/webkitscmpy/webkitscmpy/canonicalize/__init__.py:76 > '{remote}/{branch}..{branch}'.format(remote=args.remote, branch=branch), test
Jonathan Bedard
Comment 23 2021-01-06 07:09:24 PST
(In reply to Aakash Jain from comment #21) > > Tools/Scripts/libraries/webkitscmpy/webkitscmpy/canonicalize/__init__.py:62 > > if not repository.path: > > Should repository.path be changed here as well? root_path is derived from path, what we're basically checking for here is "is the repository the user specified something actually existing on the filesystem, or is it referring to a remote repository accessed via a web API"
Jonathan Bedard
Comment 24 2021-01-06 08:00:16 PST
Created attachment 417084 [details] Patch for landing
EWS
Comment 25 2021-01-06 10:15:05 PST
Committed r271203: <https://trac.webkit.org/changeset/271203> All reviewed patches have been landed. Closing bug and clearing flags on attachment 417084 [details].
Jonathan Bedard
Comment 26 2021-01-07 08:44:03 PST
A follow-up note on this change: We are now using this script in the post-commit SVN hook to push to https://github.com/WebKit/WebKit.
Note You need to log in before you can comment on or make changes to this bug.