Skip to content

Conversation

@therazix
Copy link
Contributor

@therazix therazix commented Oct 14, 2025

  • URLs ending with .git should now produce the same hash as those not ending with .git.
  • Hashes are consistent across runs.
  • Updated logging to include the exact git error message.
  • Added a function that checks for potential changes and logs them before reverting - this should prevent errors during branch updates and provide more insight into what’s happening.

Fixes #23

@codiumai-pr-agent-free
Copy link

PR Type

Bug fix, Enhancement


Description

  • Replace Python's hash() with SHA-1 for consistent repository path generation

  • Normalize repository URLs by removing trailing .git suffix

  • Enhance git fetch with explicit refspec and pruning options

  • Add dedicated hash creation utility function for security-disabled SHA-1


Diagram Walkthrough

flowchart LR
  A["Repository URL"] --> B["Normalize URL"]
  B --> C["Create SHA-1 Hash"]
  C --> D["Generate Clone Path"]
  E["Git Fetch"] --> F["Prune Remote Refs"]
  F --> G["Update Local Branches"]
Loading

File Walkthrough

Relevant files
Bug fix
git_handler.py
Improve repository caching and branch synchronization       

src/tmt_web/utils/git_handler.py

  • Added create_hash() function using SHA-1 for deterministic hashing
    across runs
  • Modified get_unique_clone_path() to normalize URLs and use SHA-1
    instead of Python's hash()
  • Enhanced _fetch_remote() with explicit refspecs, pruning flags, and
    origin specification
+22/-3   

@codiumai-pr-agent-free
Copy link

codiumai-pr-agent-free bot commented Oct 14, 2025

This app will be decommissioned on Dec 1st. Please remove this app and install Qodo Git.

PR Compliance Guide 🔍

(Compliance updated until commit ceeb02f)

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🟢
🎫 #23
🟢 Fix the error when git repository URL contains the `.git` suffix
Make URLs with `.git` suffix work the same as URLs without it
Fix the "Failed to update branch" error for repositories with `.git` in the URL
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status: Passed

Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status: Passed

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status: Passed

Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

Previous compliance checks

Compliance check up to commit 5b1a97e
Security Compliance
Non-secure hash usage

Description: The code explicitly sets usedforsecurity=False when creating a SHA-1 hash, which is
appropriate for non-security purposes but should be verified that this hash is not used
for any security-critical operations elsewhere. git_handler.py [26-26]

Referred Code
hashed_url = hashlib.new("sha1", usedforsecurity=False)
hashed_url.update(text.encode())
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
No custom compliance provided

Follow the guide to enable custom compliance check.

The managed version of the open source project PR-Agent is sunsetting on the 1st December 2025. The commercial version of this project will remain available and free to use as a hosted service. Install Qodo.

@codiumai-pr-agent-free
Copy link

codiumai-pr-agent-free bot commented Oct 14, 2025

PR Code Suggestions ✨

No code suggestions found for the PR.

@therazix therazix force-pushed the fvagner-branch-update-fix branch from 5b1a97e to ceeb02f Compare October 15, 2025 07:41
@therazix therazix changed the title Fix branch updating and caching Fix branch updating and caching in git handler Oct 15, 2025
@psss psss added this to planning Oct 20, 2025
@github-project-automation github-project-automation bot moved this to backlog in planning Oct 20, 2025
@psss psss moved this from backlog to review in planning Oct 20, 2025
@happz happz requested review from janhavlin and psss October 21, 2025 11:06
@thrix thrix self-requested a review November 19, 2025 09:30
Copy link
Contributor

@janhavlin janhavlin left a comment

Choose a reason for hiding this comment

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

Tried it out locally on some examples and ran into no issues.

Copy link
Contributor

@psss psss left a comment

Choose a reason for hiding this comment

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

Looks good, just one concern.

@psss psss merged commit 5735021 into main Nov 21, 2025
3 checks passed
@psss psss deleted the fvagner-branch-update-fix branch November 21, 2025 09:18
@github-project-automation github-project-automation bot moved this from review to done in planning Nov 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: done

Development

Successfully merging this pull request may close these issues.

Fail to update branch when .git present in the url

4 participants