Skip to content

VALIDATE_ALL_CODEBASE: false fails to detect modified files in GitLab MR pipelines due to bare git diff on detached HEAD #8356

Description

@srikant-sahu

Describe the bug
When using MegaLinter in a GitLab CI Merge Request pipeline with VALIDATE_ALL_CODEBASE: "false", the engine fails to detect any changed files.
The Updated Sources Reporter outputs No source file has been formatted or fixed and skips all file validations. This happens because MegaLinter's underlying Python process executes a bare workspace diff (git diff --abbrev=40 --full-index -M --raw -z --no-color), which returns zero results in environments using clean detached HEAD checkouts (like GitLab Runner)

To Reproduce
Steps to reproduce the behavior:

  1. Create a GitLab CI pipeline targeted at a Merge Request event ($CI_PIPELINE_SOURCE == "merge_request_event").
  2. Set VALIDATE_ALL_CODEBASE: "false" and GIT_DEPTH: 0.
  3. Push changes to a feature branch and open a Merge Request.
  4. Observe the MegaLinter log. It will state that 0 files were updated/found despite active file differences existing between the source and target branch
    Logs from job:
    Start updated Sources Reporter
    sys.platform='linux', git_executable='git'
    Popen(['git', 'diff', '--abbrev=40', '--full-index', '-M', '--raw', '-z', '--no-color'], cwd=/builds/..., stdin=None, shell=False, universal_newlines=False)
    Updated files :
    [Updated Sources Reporter] No source file has been formatted or fixed

Expected behavior
Expect to see the new/modified files in the Updated files output and associated linters to run.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions