Skip to content

Conversation

@pcfreak30
Copy link
Member

@pcfreak30 pcfreak30 commented Jan 23, 2026

This pull request moves the retrieval of the Git commit hash to occur after the Git commit operation in the release script. Previously, the commit hash was captured before any Git operations were performed. The change ensures that the hash retrieved corresponds to the actual commit that was just created, rather than potentially capturing a different commit state. This modification improves the accuracy of metadata tracking by associating the correct commit hash with the release changes.

@pcfreak30 pcfreak30 merged commit be36c90 into develop Jan 23, 2026
2 checks passed
@kody-ai
Copy link

kody-ai bot commented Jan 23, 2026

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug
Performance
Security
Cross File

Access your configuration settings here.

copier = SafeBuildCopier(repo_root, args.verbose)
copier.copy_targets(targets)

# Write metadata for downstream workflows
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kody code-review Bug medium

The commit hash retrieval logic is duplicated and incorrectly ordered in scripts/release-go.py. The commit hash is captured after git operations but write_metadata_files() is called before this capture, causing metadata to always have None commit hash. Additionally, the git hash retrieval code appears twice in the file (lines 964-968 and 1003-1012) with identical logic.

This issue appears in multiple locations:

  • scripts/release-go.py: Lines 964-1020
  • scripts/release-go.py: Lines 1003-1012
    Please extract the git commit hash retrieval into a shared utility function and ensure write_metadata_files() is called after the commit hash is captured, not before the git operations.
        # Write metadata for downstream workflows
        modified_apps = copier.get_modified_apps_list(targets)
        
        # Git operations
        commit_hash = None
        if not args.no_push:
            # Stage and commit changes
            result = subprocess.run(
                ["git", "add", "go/"],
                cwd=repo_root,
                capture_output=True,
                text=True
            )
            
            if result.returncode != 0:
                logger.error(f"Failed to stage changes: {result.stderr}")
                return 1
            
            # Check if there are changes to commit
            status_result = subprocess.run(
                ["git", "status", "--porcelain", "go/"],
                cwd=repo_root,
                capture_output=True,
                text=True
            )
            
            if status_result.returncode == 0 and status_result.stdout.strip():
                logger.info("Changes detected, committing...")
                commit_result = subprocess.run(
                    ["git", "commit", "-m", "chore: export app and plugin builds"],
                    cwd=repo_root,
                    capture_output=True,
                    text=True
                )
                
                if commit_result.returncode != 0:
                    logger.error(f"Failed to commit changes: {commit_result.stderr}")
                    return 1
                
                try:
                    hash_result = subprocess.run(
                        ["git", "rev-parse", "HEAD"],
                        cwd=repo_root,
                        capture_output=True,
                        text=True
                    )
                    commit_hash = hash_result.stdout.strip() if hash_result.returncode == 0 else None
                except:
                    commit_hash = None
                
                # Push changes
                push_result = subprocess.run(
                    ["git", "push"],
                    cwd=repo_root,
                    capture_output=True,
                    text=True
                )
                
                if push_result.returncode != 0:
                    logger.error(f"Failed to push changes: {push_result.stderr}")
                    return 1
                
                logger.info("Changes pushed successfully")
            else:
                logger.info("No changes to commit")
        else:
            logger.info("Skipping git operations (no-push specified)")
        
        write_metadata_files(modified_apps, commit_hash, args.verbose)
Prompt for LLM

File scripts/release-go.py:

Line 964:

I need you to analyze a Python script that handles Git operations and metadata writing. The issue is that the commit hash is only captured after a successful git commit operation, but the write_metadata_files() function is called before this capture happens. This means the metadata file will always have a None commit hash even when a commit was successfully made. Can you identify the exact problem and suggest how to fix the order of operations so that the commit hash is properly captured before writing the metadata files?

Suggested Code:

        # Write metadata for downstream workflows
        modified_apps = copier.get_modified_apps_list(targets)
        
        # Git operations
        commit_hash = None
        if not args.no_push:
            # Stage and commit changes
            result = subprocess.run(
                ["git", "add", "go/"],
                cwd=repo_root,
                capture_output=True,
                text=True
            )
            
            if result.returncode != 0:
                logger.error(f"Failed to stage changes: {result.stderr}")
                return 1
            
            # Check if there are changes to commit
            status_result = subprocess.run(
                ["git", "status", "--porcelain", "go/"],
                cwd=repo_root,
                capture_output=True,
                text=True
            )
            
            if status_result.returncode == 0 and status_result.stdout.strip():
                logger.info("Changes detected, committing...")
                commit_result = subprocess.run(
                    ["git", "commit", "-m", "chore: export app and plugin builds"],
                    cwd=repo_root,
                    capture_output=True,
                    text=True
                )
                
                if commit_result.returncode != 0:
                    logger.error(f"Failed to commit changes: {commit_result.stderr}")
                    return 1
                
                try:
                    hash_result = subprocess.run(
                        ["git", "rev-parse", "HEAD"],
                        cwd=repo_root,
                        capture_output=True,
                        text=True
                    )
                    commit_hash = hash_result.stdout.strip() if hash_result.returncode == 0 else None
                except:
                    commit_hash = None
                
                # Push changes
                push_result = subprocess.run(
                    ["git", "push"],
                    cwd=repo_root,
                    capture_output=True,
                    text=True
                )
                
                if push_result.returncode != 0:
                    logger.error(f"Failed to push changes: {push_result.stderr}")
                    return 1
                
                logger.info("Changes pushed successfully")
            else:
                logger.info("No changes to commit")
        else:
            logger.info("Skipping git operations (no-push specified)")
        
        write_metadata_files(modified_apps, commit_hash, args.verbose)

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants