mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 15:12:06 +00:00 
			
		
		
		
	Fix list-components when PR is not targeting dev (#6375)
This commit is contained in:
		| @@ -70,11 +70,11 @@ def splitlines_no_ends(string): | ||||
|     return [s.strip() for s in string.splitlines()] | ||||
|  | ||||
|  | ||||
| def changed_files(): | ||||
| def changed_files(branch="dev"): | ||||
|     check_remotes = ["upstream", "origin"] | ||||
|     check_remotes.extend(splitlines_no_ends(get_output("git", "remote"))) | ||||
|     for remote in check_remotes: | ||||
|         command = ["git", "merge-base", f"refs/remotes/{remote}/dev", "HEAD"] | ||||
|         command = ["git", "merge-base", f"refs/remotes/{remote}/{branch}", "HEAD"] | ||||
|         try: | ||||
|             merge_base = splitlines_no_ends(get_output(*command))[0] | ||||
|             break | ||||
|   | ||||
| @@ -120,13 +120,22 @@ def main(): | ||||
|     parser.add_argument( | ||||
|         "-c", "--changed", action="store_true", help="Only run on changed files" | ||||
|     ) | ||||
|     parser.add_argument( | ||||
|         "-b", "--branch", help="Branch to compare changed files against" | ||||
|     ) | ||||
|     args = parser.parse_args() | ||||
|  | ||||
|     if args.branch and not args.changed: | ||||
|         parser.error("--branch requires --changed") | ||||
|  | ||||
|     files = git_ls_files() | ||||
|     files = filter(filter_component_files, files) | ||||
|  | ||||
|     if args.changed: | ||||
|         changed = changed_files() | ||||
|         if args.branch: | ||||
|             changed = changed_files(args.branch) | ||||
|         else: | ||||
|             changed = changed_files() | ||||
|         files = [f for f in files if f in changed] | ||||
|  | ||||
|     components = extract_component_names_array_from_files_array(files) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user