mirror of
				https://github.com/Mbed-TLS/mbedtls.git
				synced 2025-10-28 23:14:56 +03:00 
			
		
		
		
	Merge pull request #8004 from daverodgman/code_style_since-2.28
backport 2.28 - Make code_style.py --since more precise
This commit is contained in:
		| @@ -81,11 +81,15 @@ def get_src_files(since: Optional[str]) -> List[str]: | |||||||
|                                      universal_newlines=True) |                                      universal_newlines=True) | ||||||
|     src_files = output.split() |     src_files = output.split() | ||||||
|     if since: |     if since: | ||||||
|         output = subprocess.check_output(["git", "diff", "--name-only", |         # get all files changed in commits since the starting point | ||||||
|                                           since, "--"] + |         cmd = ["git", "log", since + "..HEAD", "--name-only", "--pretty=", "--"] + src_files | ||||||
|                                          src_files, |         output = subprocess.check_output(cmd, universal_newlines=True) | ||||||
|                                          universal_newlines=True) |         committed_changed_files = output.split() | ||||||
|         src_files = output.split() |         # and also get all files with uncommitted changes | ||||||
|  |         cmd = ["git", "diff", "--name-only", "--"] + src_files | ||||||
|  |         output = subprocess.check_output(cmd, universal_newlines=True) | ||||||
|  |         uncommitted_changed_files = output.split() | ||||||
|  |         src_files = list(set(committed_changed_files + uncommitted_changed_files)) | ||||||
|  |  | ||||||
|     generated_files = list_generated_files() |     generated_files = list_generated_files() | ||||||
|     # Don't correct style for third-party files (and, for simplicity, |     # Don't correct style for third-party files (and, for simplicity, | ||||||
| @@ -189,9 +193,10 @@ def main() -> int: | |||||||
|     parser.add_argument('-f', '--fix', action='store_true', |     parser.add_argument('-f', '--fix', action='store_true', | ||||||
|                         help=('modify source files to fix the code style ' |                         help=('modify source files to fix the code style ' | ||||||
|                               '(default: print diff, do not modify files)')) |                               '(default: print diff, do not modify files)')) | ||||||
|     parser.add_argument('-s', '--since', metavar='COMMIT', |     parser.add_argument('-s', '--since', metavar='COMMIT', const='mbedtls-2.28', nargs='?', | ||||||
|                         help=('only check files modified since the specified commit' |                         help=('only check files modified since the specified commit' | ||||||
|                               ' (e.g. --since=HEAD~3 or --since=development)')) |                               ' (e.g. --since=HEAD~3 or --since=mbedtls-2.28). If no' | ||||||
|  |                               ' commit is specified, default to mbedtls-2.28.')) | ||||||
|     # --subset is almost useless: it only matters if there are no files |     # --subset is almost useless: it only matters if there are no files | ||||||
|     # ('code_style.py' without arguments checks all files known to Git, |     # ('code_style.py' without arguments checks all files known to Git, | ||||||
|     # 'code_style.py --subset' does nothing). In particular, |     # 'code_style.py --subset' does nothing). In particular, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user