aider: Added logging to print out the commit hashes for local_main and origin_main before the comparison to diagnose the issue with the script reporting that the main branch is not up to date with origin/main even though it is.

# Aider chat conversation:

USER: it's printing Error: The main branch is not up to date with origin/main. even though main is up to date with origin/main

ASSISTANT: To address the issue you're experiencing with the script reporting that the main branch is not up to date with `origin/main` even though it is, we should add additional logging to the script to help diagnose the problem. We can print out the commit hashes for `local_main` and `origin_main` before the comparison to see what the script is actually getting from the `git` commands.

Let's modify the `scripts/versionbump.py` file to add this logging.

Here is the *SEARCH/REPLACE* block:

scripts/versionbump.py
```python
<<<<<<< SEARCH
        local_main = subprocess.run(["git", "rev-parse", "main"], capture_output=True, text=True).stdout.strip()
        origin_main = subprocess.run(["git", "rev-parse", "origin/main"], capture_output=True, text=True).stdout.strip()
        if local_main != origin_main:
            print("Error: The main branch is not up to date with origin/main.")
=======
        local_main = subprocess.run(["git", "rev-parse", "main"], capture_output=True, text=True).stdout.strip()
        print(f"Local main commit hash: {local_main}")
        origin_main = subprocess.run(["git", "rev-parse", "origin/main"], capture_output=True, text=True).stdout.strip()
        print(f"Origin main commit hash: {origin_main}")
        if local_main != origin_main:
            print("Error: The main branch is not up to date with origin/main. Please pull the latest changes.")
>>>>>>> REPLACE
```

This change will print out the commit hashes for both `local_main` and `origin_main` before the script checks if they are the same. This should help you diagnose why the script thinks the branches are not in sync. If the hashes are indeed the same, but the script still reports an error, it could be an issue with the script's logic or the environment in which it's being run.
This commit is contained in:
Paul Gauthier 2023-11-17 15:48:59 -08:00
parent 3bd716e46d
commit 21b80d0c06

View file

@ -32,9 +32,11 @@ def main():
def check_main_branch_up_to_date(): def check_main_branch_up_to_date():
subprocess.run(["git", "fetch", "origin"], check=True) subprocess.run(["git", "fetch", "origin"], check=True)
local_main = subprocess.run(["git", "rev-parse", "main"], capture_output=True, text=True).stdout.strip() local_main = subprocess.run(["git", "rev-parse", "main"], capture_output=True, text=True).stdout.strip()
print(f"Local main commit hash: {local_main}")
origin_main = subprocess.run(["git", "rev-parse", "origin/main"], capture_output=True, text=True).stdout.strip() origin_main = subprocess.run(["git", "rev-parse", "origin/main"], capture_output=True, text=True).stdout.strip()
print(f"Origin main commit hash: {origin_main}")
if local_main != origin_main: if local_main != origin_main:
print("Error: The main branch is not up to date with origin/main.") print("Error: The main branch is not up to date with origin/main. Please pull the latest changes.")
sys.exit(1) sys.exit(1)
args = parser.parse_args() args = parser.parse_args()