Changeset 291716 in webkit
- Timestamp:
- Mar 22, 2022, 4:00:11 PM (5 years ago)
- Location:
- trunk/Tools
- Files:
-
- 5 edited
-
ChangeLog (modified) (1 diff)
-
Scripts/libraries/webkitscmpy/setup.py (modified) (1 diff)
-
Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py (modified) (1 diff)
-
Scripts/libraries/webkitscmpy/webkitscmpy/program/setup.py (modified) (6 diffs)
-
Scripts/libraries/webkitscmpy/webkitscmpy/test/setup_unittest.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r291627 r291716 1 2022-03-22 Jonathan Bedard <jbedard@apple.com> 2 3 [git-webkit] Do not re-prompt configuration options during setup 4 https://bugs.webkit.org/show_bug.cgi?id=237571 5 <rdar://problem/89940351> 6 7 Reviewed by Dewei Zhu. 8 9 * Scripts/libraries/webkitscmpy/setup.py: Bump version. 10 * Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py: Ditto. 11 * Scripts/libraries/webkitscmpy/webkitscmpy/program/setup.py: 12 (Setup.git): Skip already configured options by default. 13 (Setup.parser): Add option to re-prompt for previously configured options. 14 * Scripts/libraries/webkitscmpy/webkitscmpy/test/setup_unittest.py: 15 1 16 2022-03-22 Jonathan Bedard <jbedard@apple.com> 2 17 -
trunk/Tools/Scripts/libraries/webkitscmpy/setup.py
r291490 r291716 30 30 setup( 31 31 name='webkitscmpy', 32 version='4.4. 1',32 version='4.4.2', 33 33 description='Library designed to interact with git and svn repositories.', 34 34 long_description=readme(), -
trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/__init__.py
r291490 r291716 47 47 ) 48 48 49 version = Version(4, 4, 1)49 version = Version(4, 4, 2) 50 50 51 51 AutoInstall.register(Package('fasteners', Version(0, 15, 0))) -
trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/setup.py
r291138 r291716 81 81 @classmethod 82 82 def git(cls, args, repository, additional_setup=None, hooks=None, **kwargs): 83 local_config = repository.config() 83 84 global_config = local.Git.config() 84 85 result = 0 85 86 86 email = os.environ.get('EMAIL_ADDRESS') or global_config.get('user.email') 87 email = os.environ.get('EMAIL_ADDRESS') or global_config.get('user.email') or local_config.get('user.email') 87 88 log.info('Setting git user email for {}...'.format(repository.root_path)) 88 if not email or args.defaults is False or (not args.defaults and Terminal.choose(89 if not email or args.defaults is False or (not args.defaults and args.all and Terminal.choose( 89 90 "Set '{}' as the git user email for this repository".format(email), 90 91 default='Yes', … … 92 93 email = Terminal.input('Enter git user email for this repository: ') 93 94 94 if run( 95 [local.Git.executable(), 'config', 'user.email', email], capture_output=True, cwd=repository.root_path, 96 ).returncode: 97 sys.stderr.write('Failed to set the git user email to {} for this repository\n'.format(email)) 98 result += 1 99 else: 100 log.info("Set git user email to '{}' for this repository".format(email)) 101 102 name = repository.contributors.get(email) 103 if name: 104 name = name.name 105 else: 106 name = global_config.get('user.name') 95 if email != local_config.get('user.email'): 96 if run( 97 [local.Git.executable(), 'config', 'user.email', email], capture_output=True, cwd=repository.root_path, 98 ).returncode: 99 sys.stderr.write('Failed to set the git user email to {} for this repository\n'.format(email)) 100 result += 1 101 else: 102 log.info("Set git user email to '{}' for this repository".format(email)) 103 else: 104 log.info("Skipped setting email to '{}', it's already set for this repository".format(email)) 105 106 contributor = repository.contributors.get(email) 107 if contributor: 108 name = contributor.name 109 else: 110 name = global_config.get('user.name') or local_config.get('user.name') 107 111 log.info('Setting git user name for {}...'.format(repository.root_path)) 108 if not name or args.defaults is False or (not args.defaults and Terminal.choose(112 if not name or args.defaults is False or (not args.defaults and args.all and Terminal.choose( 109 113 "Set '{}' as the git user name for this repository".format(name), 110 114 default='Yes', 111 115 ) == 'No'): 112 116 name = Terminal.input('Enter git user name for this repository: ') 113 if run( 114 [local.Git.executable(), 'config', 'user.name', name], capture_output=True, cwd=repository.root_path, 115 ).returncode: 116 sys.stderr.write('Failed to set the git user name to {} for this repository\n'.format(name)) 117 result += 1 118 else: 119 log.info("Set git user name to '{}' for this repository".format(name)) 117 118 if name != local_config.get('user.name'): 119 if run( 120 [local.Git.executable(), 'config', 'user.name', name], capture_output=True, cwd=repository.root_path, 121 ).returncode: 122 sys.stderr.write('Failed to set the git user name to {} for this repository\n'.format(name)) 123 result += 1 124 else: 125 log.info("Set git user name to '{}' for this repository".format(name)) 126 else: 127 log.info("Skipped setting name to '{}', it's already set for this repository".format(name)) 120 128 121 129 if repository.metadata and os.path.isfile(os.path.join(repository.metadata, local.Git.GIT_CONFIG_EXTENSION)): … … 140 148 log.info('Set better Objective-C diffing behavior for this repository!') 141 149 142 if args.defaults or Terminal.choose( 150 commands_to_color = ('color.status', 'color.diff', 'color.branch') 151 need_prompt_color = args.all or any([not local_config.get(command) for command in commands_to_color]) 152 if args.defaults or (need_prompt_color and Terminal.choose( 143 153 'Auto-color status, diff, and branch for this repository?', 144 default='Yes', 145 ) == 'Yes': 146 for command in ('status', 'diff', 'branch'): 147 result += run( 148 [local.Git.executable(), 'config', 'color.{}'.format(command), 'auto'], 149 capture_output=True, cwd=repository.root_path, 150 ).returncode 154 default='Yes', options=('Yes', 'Skip'), 155 ) == 'Yes'): 156 for command in commands_to_color: 157 if not local_config.get(command): 158 result += run( 159 [local.Git.executable(), 'config', command, 'auto'], 160 capture_output=True, cwd=repository.root_path, 161 ).returncode 151 162 152 163 if args.merge is None: … … 160 171 result += 1 161 172 162 if repository.config(location='project')['webkitscmpy.history'] == 'never': 163 pr_history = 'never' 164 elif repository.config(location='project')['webkitscmpy.pull-request'] != 'overwrite': 165 pr_history = None 166 elif args.defaults: 167 pr_history = repository.config(location='project')['webkitscmpy.history'] 168 else: 169 pr_history = Terminal.choose( 170 'Would you like to create new branches to retain history when you overwrite\na pull request branch?', 171 default=repository.config(location='project')['webkitscmpy.history'], 172 options=repository.PROJECT_CONFIG_OPTIONS['webkitscmpy.history'], 173 ) 174 if pr_history and run( 175 [local.Git.executable(), 'config', 'webkitscmpy.history', pr_history], 176 capture_output=True, cwd=repository.root_path, 177 ).returncode: 178 sys.stderr.write("Failed to set '{}' as the default history management approach\n".format(pr_history)) 179 result += 1 173 if args.all or not local_config.get('webkitscmpy.history'): 174 if repository.config(location='project')['webkitscmpy.history'] == 'never': 175 pr_history = 'never' 176 elif repository.config(location='project')['webkitscmpy.pull-request'] != 'overwrite': 177 pr_history = None 178 elif args.defaults: 179 pr_history = repository.config(location='project')['webkitscmpy.history'] 180 else: 181 pr_history = Terminal.choose( 182 'Would you like to create new branches to retain history when you overwrite\na pull request branch?', 183 default=repository.config(location='project')['webkitscmpy.history'], 184 options=repository.PROJECT_CONFIG_OPTIONS['webkitscmpy.history'], 185 ) 186 if pr_history and run( 187 [local.Git.executable(), 'config', 'webkitscmpy.history', pr_history], 188 capture_output=True, cwd=repository.root_path, 189 ).returncode: 190 sys.stderr.write("Failed to set '{}' as the default history management approach\n".format(pr_history)) 191 result += 1 180 192 181 193 if hooks: … … 201 213 os.chmod(target, 0o775) 202 214 203 log.info('Setting git editor for {}...'.format(repository.root_path)) 204 editor_name = 'default' if args.defaults else Terminal.choose( 205 'Pick a commit message editor for this repository', 206 options=['default'] + [program.name for program in Editor.programs()], 207 default='default', 208 numbered=True, 209 ) 210 if editor_name == 'default': 211 log.info('Using the default git editor for this repository') 212 elif run( 213 [local.Git.executable(), 'config', 'core.editor', ' '.join([arg.replace(' ', '\\ ') for arg in Editor.by_name(editor_name).wait])], 214 capture_output=True, 215 cwd=repository.root_path, 216 ).returncode: 217 sys.stderr.write('Failed to set the git editor to {} for this repository\n'.format(editor_name)) 218 result += 1 219 else: 220 log.info("Set git editor to '{}' for this repository".format(editor_name)) 215 if args.all or not local_config.get('core.editor'): 216 log.info('Setting git editor for {}...'.format(repository.root_path)) 217 editor_name = 'default' if args.defaults else Terminal.choose( 218 'Pick a commit message editor for this repository', 219 options=['default'] + [program.name for program in Editor.programs()], 220 default='default', 221 numbered=True, 222 ) 223 if editor_name == 'default': 224 log.info('Using the default git editor for this repository') 225 elif run( 226 [local.Git.executable(), 'config', 'core.editor', ' '.join([arg.replace(' ', '\\ ') for arg in Editor.by_name(editor_name).wait])], 227 capture_output=True, 228 cwd=repository.root_path, 229 ).returncode: 230 sys.stderr.write('Failed to set the git editor to {} for this repository\n'.format(editor_name)) 231 result += 1 232 else: 233 log.info("Set git editor to '{}' for this repository".format(editor_name)) 221 234 222 235 # Pushing to http repositories is difficult, offer to change http checkouts to ssh … … 299 312 help='Use a merge-commit workflow instead of a rebase workflow', 300 313 ) 314 parser.add_argument( 315 '--all', '-a', action='store_true', default=False, 316 help='Prompt the user for all options, do not assume responses from the current configuration', 317 ) 301 318 302 319 @classmethod -
trunk/Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/setup_unittest.py
r290661 r291716 69 69 70 70 def test_git(self): 71 self.maxDiff = None 71 72 with OutputCapture(level=logging.INFO) as captured, mocks.local.Git(self.path) as repo, \ 72 73 mocks.local.Svn(), wkmocks.Environment(EMAIL_ADDRESS=''): … … 95 96 captured.root.log.getvalue(), 96 97 '''Setting git user email for {repository}... 97 S et git user email to 'tapple@webkit.org'for this repository98 Skipped setting email to 'tapple@webkit.org', it's already set for this repository 98 99 Setting git user name for {repository}... 99 S et git user name to 'Tim Apple'for this repository100 Skipped setting name to 'Tim Apple', it's already set for this repository 100 101 No project git config found, continuing 101 102 Setting better Objective-C diffing behavior for this repository... … … 110 111 self.maxDiff = None 111 112 with OutputCapture(level=logging.INFO) as captured, mocks.remote.GitHub() as remote, \ 112 MockTerminal.input('n', 'n', 'committer@webkit.org', 'n', 'Committer', ' n', 'overwrite', 'disabled', '1', 'y', 'y'), \113 MockTerminal.input('n', 'n', 'committer@webkit.org', 'n', 'Committer', 's', 'overwrite', 'disabled', '1', 'y', 'y'), \ 113 114 mocks.local.Git(self.path, remote='https://{}.git'.format(remote.remote)) as repo, \ 114 115 wkmocks.Environment(EMAIL_ADDRESS=''): … … 117 118 118 119 self.assertEqual(0, program.main( 119 args=('setup', '-v' ),120 args=('setup', '-v', '-a'), 120 121 path=self.path, 121 122 )) … … 139 140 Set 'Tim Apple' as the git user name for this repository ([Yes]/No): 140 141 Enter git user name for this repository: 141 Auto-color status, diff, and branch for this repository? ([Yes]/ No):142 Auto-color status, diff, and branch for this repository? ([Yes]/Skip): 142 143 Would you like to create new branches to retain history when you overwrite 143 144 a pull request branch? ([when-user-owned]/disabled/always/never):
Note:
See TracChangeset
for help on using the changeset viewer.