0

I'm working on an install profile right now in Drupal (https://www.drupal.org/sandbox/jnicola/3277854). I want to while developing the next project we're on also build this out during the initial part of building our site out.

I can load the sandbox project via composer no problem, and it's checked out via git, but when I run git status I get "HEAD detached at 56eaaa5"

I'd like the sandbox repo to be checked out on the active development branch, and I want to be able to work inside of that project inside of Drupal in general.

It is fairly important that this is brought in via composer as well, since I will be adding modules requirements into the sandboxes composer.json file for the overall project, so I believe bringing in the repo as a "submodule" wouldn't work, even though that is the desired functionality.

2
  • My answer below is the way. Avoid Git submodules.
    – cilefen
    May 20, 2022 at 20:50
  • Yes, git submodules are needlessly complex for this line of work usually.
    – Kevin
    May 20, 2022 at 21:05

1 Answer 1

0

Reference this project version in composer.json as 1.0.x-dev. This is documented by Composer. Composer checks out a commit, so cd into the project working copy and type git checkout 1.0.x.

In detail, composer.json should contain this in the repositories section:

        {
            "type": "vcs",
            "url": "https://git.drupalcode.org/sandbox/jnicola-3277854.git"
        }

Then you type:

composer require 'drupal/simple_grouped_content:1.0.x-dev'
cd profiles/contrib/simple_group_content
git checkout 1.0.x

This is a Composer question rather than a Drupal question.

5
  • Yes, they commit and push to that sandbox, every time you composer update (module) it will pull changes.
    – Kevin
    May 20, 2022 at 20:14
  • Use 1.0.x-dev@dev if there is a conflict with the minimum-stability set in this project.
    – cilefen
    May 20, 2022 at 20:31
  • Is there a way to make this work where the branch is checked out by default and not starting in a detatched state? It's minor, I know, but my teammates will use any excuse to complain about this methodology, no matter how minor.
    – Jnicola
    May 20, 2022 at 21:46
  • That’s a Composer question. I am not sure there is a way. See also drupal.stackexchange.com/questions/291875/…
    – cilefen
    May 20, 2022 at 22:50
  • Here is the same question again, ten years ago: stackoverflow.com/questions/12284090/… It as answered by the Composer team lead. But the OP actually opened the feature request as asked, and according to the feature they did change the behavior but were concerned about side effects: github.com/composer/composer/issues/1164 Maybe they reverted it.
    – cilefen
    May 21, 2022 at 11:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.