Bug 171085

Summary: commit-log-editor should respect the git editor if one is set
Product: WebKit Reporter: Conrad Shultz <conrad_shultz>
Component: Tools / TestsAssignee: Conrad Shultz <conrad_shultz>
Status: RESOLVED FIXED    
Severity: Normal CC: conrad_shultz, dbates, kocsen_chung, lforschler, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch dbates: review+

Conrad Shultz
Reported 2017-04-20 15:56:54 PDT
commit-log-editor currently will consider SVN and CVS editor preferences. It should also respect the git editor if one is set through GIT_EDITOR or the global git config.
Attachments
Patch (1.36 KB, patch)
2017-04-20 16:01 PDT, Conrad Shultz
no flags
Patch (1.49 KB, patch)
2017-04-20 17:01 PDT, Conrad Shultz
dbates: review+
Conrad Shultz
Comment 1 2017-04-20 16:01:08 PDT
Radar WebKit Bug Importer
Comment 2 2017-04-20 16:02:51 PDT
Kocsen Chung
Comment 3 2017-04-20 16:16:30 PDT
Changes look good. For git/git-svn users, have we considered using a `prepare-commit-msg` hook (https://git-scm.com/docs/githooks#_prepare_commit_msg). And allow git to deal with the "editor setting" logic?
Conrad Shultz
Comment 4 2017-04-20 16:17:54 PDT
(In reply to Kocsen Chung from comment #3) > Changes look good. > > For git/git-svn users, have we considered using a `prepare-commit-msg` hook > (https://git-scm.com/docs/githooks#_prepare_commit_msg). > And allow git to deal with the "editor setting" logic? I haven't looked into that; I tried, for now, to keep the logic as similar as possible to what we're doing for other SCMs.
Daniel Bates
Comment 5 2017-04-20 16:45:05 PDT
Comment on attachment 307656 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=307656&action=review > Tools/Scripts/commit-log-editor:97 > +if (isGit()) { > + $editor = $ENV{GIT_EDITOR}; > + $editor = `git config --global --get core.editor` if !$editor; > +} Take GIT_EDITOR := vi and "git config core.editor" := Tools/Scripts/commit-log-editor. Make a change to some file and run "git commit -a". Then Git will invoke vi directly instead of commit-log-editor by definition of GIT_EDITOR in <https://git-scm.com/docs/git-var#_variables>. That is, we never run this code. We should take a similar approach as for SVN_LOG_EDITOR and CVS_LOG_EDITOR and query for an environment variable that does not coincide with an environment variable used by Git, say GIT_LOG_EDITOR.
Conrad Shultz
Comment 6 2017-04-20 17:01:04 PDT
Conrad Shultz
Comment 7 2017-04-20 17:01:24 PDT
(In reply to Daniel Bates from comment #5) > Comment on attachment 307656 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=307656&action=review > > > Tools/Scripts/commit-log-editor:97 > > +if (isGit()) { > > + $editor = $ENV{GIT_EDITOR}; > > + $editor = `git config --global --get core.editor` if !$editor; > > +} > > Take GIT_EDITOR := vi and "git config core.editor" := > Tools/Scripts/commit-log-editor. Make a change to some file and run "git > commit -a". Then Git will invoke vi directly instead of commit-log-editor by > definition of GIT_EDITOR in <https://git-scm.com/docs/git-var#_variables>. > That is, we never run this code. > > We should take a similar approach as for SVN_LOG_EDITOR and CVS_LOG_EDITOR > and query for an environment variable that does not coincide with an > environment variable used by Git, say GIT_LOG_EDITOR. Agreed; posted a new version using GIT_LOG_EDITOR.
Daniel Bates
Comment 8 2017-04-20 17:23:42 PDT
Comment on attachment 307665 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=307665&action=review > Tools/ChangeLog:10 > + If git is available, consider GIT_LOG_EDITOR and any global git editor preference when deciding which editor to present. > + We examine the global editor preference since that may be set automatically by installers or third-party tools. Nit: git => Git (You mention Git twice in line 9) It is an unwritten convention that we tend to wrap ChangeLog lines that exceed ~100 characters. > Tools/Scripts/commit-log-editor:97 > +if (isGit()) { > + $editor = $ENV{GIT_LOG_EDITOR}; > + $editor = `git config --global --get core.editor` if !$editor; > +} The behavior of this code to query the global git core editor may surprise a person that never defines GIT_LOG_EDITOR, SVN_LOG_EDITOR, or CVS_LOG_EDITOR and uses commit-log-editor located in a Git checkout of WebKit in projects that use other version control systems because isGit() will return true (since the WebKit checkout is Git-based). Though a similar surprise may arise if a person just set GIT_LOG_EDITOR when using commit-log-editor in such a scenario.
Daniel Bates
Comment 9 2017-04-20 17:24:33 PDT
Comment on attachment 307665 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=307665&action=review > Tools/ChangeLog:4 > + https://bugs.webkit.org/show_bug.cgi?id=171085 Please add the radar bug URL, <rdar://problem/31745506>, under this line.
Conrad Shultz
Comment 10 2017-04-21 10:22:40 PDT
(In reply to Daniel Bates from comment #8) > Comment on attachment 307665 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=307665&action=review > > > Tools/ChangeLog:10 > > + If git is available, consider GIT_LOG_EDITOR and any global git editor preference when deciding which editor to present. > > + We examine the global editor preference since that may be set automatically by installers or third-party tools. > > Nit: git => Git > (You mention Git twice in line 9) Fixed in both places. > > It is an unwritten convention that we tend to wrap ChangeLog lines that > exceed ~100 characters. Fixed. > > > Tools/Scripts/commit-log-editor:97 > > +if (isGit()) { > > + $editor = $ENV{GIT_LOG_EDITOR}; > > + $editor = `git config --global --get core.editor` if !$editor; > > +} > > The behavior of this code to query the global git core editor may surprise a > person that never defines GIT_LOG_EDITOR, SVN_LOG_EDITOR, or CVS_LOG_EDITOR > and uses commit-log-editor located in a Git checkout of WebKit in projects > that use other version control systems because isGit() will return true > (since the WebKit checkout is Git-based). Though a similar surprise may > arise if a person just set GIT_LOG_EDITOR when using commit-log-editor in > such a scenario. Agreed. Also added the radar URL. Thanks for the review!
Conrad Shultz
Comment 11 2017-04-21 10:27:27 PDT
Committed r215615 = 3415f0bae58df85cfdfa29a9c84b402c73238ab1 http://svn.webkit.org/repository/webkit/trunk@215615
Note You need to log in before you can comment on or make changes to this bug.