From 0bb92995f2f626d139343b20cee137e178361efc Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Fri, 16 Jul 2021 18:56:58 -0400 Subject: [PATCH] [FIX] script git show code diff repo manifest: better support - support when different branch same commit - show warning instead error when the branch is different, but it's push --- doc/RELEASE.md | 8 +++++- script/git_show_code_diff_repo_manifest.py | 29 ++++++++++++++++++---- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/doc/RELEASE.md b/doc/RELEASE.md index 352bb8a..fc2983a 100644 --- a/doc/RELEASE.md +++ b/doc/RELEASE.md @@ -6,7 +6,13 @@ Before starting, validate [manifest/default.dev.xml](../manifest/default.dev.xml ## Clean environment before generate new release -Be sure all files are commit and push, this will erase everything in addons. +Before clean, check if existing file not committed, not pushed or in stash. +```bash +./.venv/repo forall -pc "git stash list" +./script/git_show_code_diff_repo_manifest.py +``` + +This will erase everything in addons. Useful before create docker, manifest and do a release. ```bash ./script/clean_repo_manifest.sh diff --git a/script/git_show_code_diff_repo_manifest.py b/script/git_show_code_diff_repo_manifest.py index 62edd8a..c41cdb7 100755 --- a/script/git_show_code_diff_repo_manifest.py +++ b/script/git_show_code_diff_repo_manifest.py @@ -106,11 +106,30 @@ def main(): ) dct_result["PASS"] += 1 elif branch_name != value: - print( - f"{Fore.RED}ERROR{Style.RESET_ALL} manifest revision is" - f" {branch_name} and actual revision is {value}." - ) - dct_result["ERROR"] += 1 + value_hash = git_repo.git.rev_parse(value) + if git_repo.git.rev_parse(branch_name) == value_hash: + print( + f"{Fore.GREEN}PASS{Style.RESET_ALL} Not same branch, no" + " divergence" + ) + dct_result["PASS"] += 1 + else: + # Check if the new branch is pushed + commit_branch = git_repo.git.rev_parse( + f"{organization}/{value}" + ) + if commit_branch == value_hash: + print( + f"{Fore.YELLOW}WARNING{Style.RESET_ALL} New branch" + f" '{value}', divergence, but it's push on remote." + ) + dct_result["WARNING"] += 1 + else: + print( + f"{Fore.RED}ERROR{Style.RESET_ALL} manifest revision" + f" is {branch_name} and actual revision is {value}." + ) + dct_result["ERROR"] += 1 else: print(f"{Fore.GREEN}PASS{Style.RESET_ALL}") dct_result["PASS"] += 1