Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

git:directory resolves only ref: "HEAD"; branches, tags, and commit SHAs all fail

Abierto
#306 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
58/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Tranquilo
Stack tecnológico
git, php
Área
tooling

Línea de trabajo

Comienza con fetch() y pull() en components/Git/class-gitremote.php; después sigue get_branch_tip() y resolve_branch_file_path() en components/Git/class-gitrepository.php. Usa la reproducción de blueprint proporcionada con las ramas, etiquetas, referencias remotas y el SHA de commit indicados. Se considera terminado cuando las formas de ref compatibles se resuelvan mediante git:directory de forma coherente con el runtime de JS; mantén fuera de alcance la observación independiente sobre targetFolderName, salvo que se confirme que está relacionada.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Summary

A git:directory data reference resolves only when ref is "HEAD". Branches, tags, and commit SHAs all fail, and the v1 schema documents ref as "The ref (branch, tag, or commit)".

There are two distinct failures behind this. Branches that exist on the remote fetch successfully and then fail on a local ref lookup. Tags and commit SHAs never get that far, because fetch() looks every ref up under refs/heads/.

This blocks gallery Blueprints such as blueprints/personal-crm, which uses ref: "dist/main". The JS Blueprints runtime accepts the same input, so the two runtimes diverge.

Follow-on to #292 and #294, which fixed the HEAD path through GitRemote. This is the same area, for every other ref form.

Reproduction

Save as blueprint.json, substituting each ref from the table below:

{
  "$schema": "https://playground.wordpress.net/blueprint-schema.json",
  "steps": [
    {
      "step": "installPlugin",
      "options": { "activate": false, "targetFolderName": "under-test" },
      "pluginData": {
        "resource": "git:directory",
        "url": "https://github.com/akirk/personal-crm",
        "ref": "REF_UNDER_TEST",
        "path": "/"
      }
    }
  ]
}

Run against any empty directory:

SITE=$(mktemp -d)
php blueprints.phar exec ./blueprint.json \
  --mode=create-new-site \
  --site-path="$SITE" \
  --site-url=http://localhost:8888 \
  --db-engine=sqlite

All three ref forms exist on the remote, ruling out a network/repo issue:

$ git ls-remote https://github.com/akirk/personal-crm refs/heads/main refs/heads/dist/main refs/tags/v1.1.1
48f7dc07f09945e4243a7a75cff284e519c1c652	refs/heads/dist/main
a4ec612f7fab6869859e4c60866b0641cf7bbf09	refs/heads/main
db0d844106b9703ed3731a689b9576745dd90267	refs/tags/v1.1.1

Results

ref Result Error
HEAD passes
main fails GitException: Branch file not found: main
dist/main fails GitException: Failed to resolve branch file path: dist/main
refs/heads/main fails GitException: Branch file not found: refs/heads/main
refs/heads/dist/main fails GitException: Branch file not found: refs/heads/dist/main
refs/remotes/origin/main fails GitRemoteException: Branch "refs/heads/refs/remotes/origin/main" not found on remote origin
v1.1.1 fails GitRemoteException: Branch "refs/heads/v1.1.1" not found on remote origin
refs/tags/v1.1.1 fails GitRemoteException: Branch "refs/heads/refs/tags/v1.1.1" not found on remote origin
a4ec612f7fab6869859e4c60866b0641cf7bbf09 fails GitRemoteException: Branch "refs/heads/a4ec612f..." not found on remote origin

Error

For an existing branch, the fetch succeeds and the failure comes afterward:

WordPress\Git\GitException: Failed to resolve branch file path: dist/main
  at components/Git/class-gitrepository.php:337

#0 components/Git/class-gitremote.php(297): GitRepository->get_branch_tip('dist/main')
#1 components/Blueprints/DataReference/class-datareferenceresolver.php(177): GitRemote->pull('dist/main', Array)

Code path

Existing branches fail on a local lookup. In components/Git/class-gitremote.php, fetch() writes the fetched tip to refs/remotes/<remote>/<name>. pull() then calls $this->repository->get_branch_tip( $full_branch_name ) with the caller's raw ref, against the local repository, where nothing was written at that path. HEAD is the only ref that resolves, because a local HEAD already exists.

In components/Git/class-gitrepository.php, resolve_branch_file_path() also treats the ref as a path relative to the repository root, and rejects any name containing / that does not begin with refs/heads/ or refs/remotes/. That accounts for the different message on dist/main.

Tags and commit SHAs fail earlier, at the remote lookup. fetch() builds the remote ref as 'HEAD' === $full_branch_name ? 'HEAD' : 'refs/heads/' . $branch_name, and localize_ref_name() strips only a leading refs/heads/. Any tag, commit SHA, or refs/remotes/... name is therefore requested under refs/heads/ and is not found.

Environment

  • blueprints.phar v0.9.0, and the build bundled with WordPress Studio (from v0.8.1). Same behavior on both, so this is not a regression between them.
  • PHP 8.5.5.

Possibly separate

With ref: "HEAD", options.targetFolderName appears to be ignored: the plugin installs to wp-content/plugins/git-repo regardless. Observed on every passing run across both versions, with two different targetFolderName values. Happy to split this out if it is unrelated.

Lenguaje dominante
PHP
Estrellas
62
Forks
23
Merge medio
4 h 12 min
PR fusionados (30 d)
1

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

  • Incluye un Dockerfile o un archivo de Docker Compose
  • Sin plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de WordPress/php-toolkit

Todos los issues de WordPress/php-toolkit

Issues similares

Más issues de PHP

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.