Skip to content

Conversation

@leander-dsouza
Copy link
Collaborator

@leander-dsouza leander-dsouza commented Nov 10, 2025

Basic Info

Info Please fill out this column
Ticket(s) this addresses resolves #8
Primary OS tested on Ubuntu
Is this a breaking change? No
Does this PR contain AI generated software? No

Description of contribution in a few bullet points

  • Enabled commit-specific fetching of origin on non-shallow clones containing hashes.
  • This allows us to clone PRs from repositories not tied to the source branch for history (external forks).
  • Added an explicit test skip due to failure of detection of svn in windows-2025.

Description of how this change was tested

1. Testing against vcs2l old pull requests

  • First, clone the codebase:

    git clone [email protected]:ros-infrastructure/vcs2l.git vcs2l-ext-fork
  • Next, use the following repos.yaml to get the commit hash of the following external fork:

    ---
    repositories:
      vcs2l-ext-fork:
        type: git
        url: 'https://github.com/ros-infrastructure/vcs2l.git'
        version: '4ad2dd14b0033c275e5faff7935c4a7d7581fee4'
  • Finally, update the existing repository:

    vcs import --input repos.yaml

    This will successfully checkout the repository to the specific hash.
    This step fails without this contribution with the following error message:

    === ./vcs2l-ext-fork (git) ===
    Could not checkout ref '4ad2dd14b0033c275e5faff7935c4a7d7581fee4': fatal: reference is not a tree:    4ad2dd14b0033c275e5faff7935c4a7d7581fee4

2. Test against the reproduction step in the parent issue - dirk-thomas/vcstool#258

  • Reproduction measures specified by @timor-raiman

    git clone [email protected]:timor-raiman/action-ros-ci.git -b vcs-issue && cd action-ros-ci
    git fetch origin +refs/pull/3/*:refs/remotes/origin/pr/3/*
    export PRMERGE_SHA=`git rev-parse origin/pr/3/merge`
    rm -rf new-path/ && mkdir -p new-path/
    cat test-vcs-issue.repo | envsubst | vcs import --force --recursive new-path/

@leander-dsouza leander-dsouza changed the title Enable commit-specific git fetch for compatibility with pull requests Enable commit-specific git fetch for compatibility with external forks. Nov 10, 2025
@leander-dsouza leander-dsouza force-pushed the leander-dsouza/fetch-non-shallow branch from 8c661f1 to ff48771 Compare November 10, 2025 16:22
@leander-dsouza leander-dsouza force-pushed the leander-dsouza/fetch-non-shallow branch from 85222a3 to e4d26d4 Compare November 10, 2025 16:58
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 0% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 26.86%. Comparing base (3d0f2f9) to head (e4d26d4).

Files with missing lines Patch % Lines
vcs2l/clients/git.py 0.00% 12 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #83      +/-   ##
==========================================
- Coverage   26.98%   26.86%   -0.13%     
==========================================
  Files          31       31              
  Lines        2238     2248      +10     
  Branches      392      396       +4     
==========================================
  Hits          604      604              
- Misses       1574     1584      +10     
  Partials       60       60              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@leander-dsouza leander-dsouza marked this pull request as ready for review November 10, 2025 17:01
Copilot AI review requested due to automatic review settings November 10, 2025 17:01
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request adds support for fetching specific commit hashes in non-shallow Git import mode, and improves test skipping for VCS tools that may not be installed.

  • Refactored version type determination to work for both shallow and non-shallow modes
  • Added explicit fetch of commit hashes for non-shallow repository imports
  • Added test skipping when SVN or Mercurial tools are not available

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
vcs2l/clients/git.py Refactored to determine version type earlier and fetch specific commit hashes in non-shallow mode for both existing and new repositories
test/test_commands.py Added utility variables and skip decorator for tests requiring SVN and Mercurial
test/reimport_force.txt Updated expected output to include fetch messages for commit hash imports
test/import.txt Updated expected output to include fetch messages for commit hash imports

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.

git client only fetches commit in shallow mode

3 participants