Score:0

How to load a sandbox project via composer and enable other devs on project to commit to the sandbox project

me flag

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.

id flag
My answer below is the way. Avoid Git submodules.
Kevin avatar
in flag
Yes, git submodules are needlessly complex for this line of work usually.
Score:0
id flag

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.

Kevin avatar
in flag
Yes, they commit and push to that sandbox, every time you composer update (module) it will pull changes.
id flag
Use `1.0.x-dev@dev` if there is a conflict with the minimum-stability set in this project.
me flag
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.
id flag
That’s a Composer question. I am not sure there is a way. See also https://drupal.stackexchange.com/questions/291875/how-can-i-prevent-composer-from-detaching-a-modules-head
id flag
Here is the same question again, ten years ago: https://stackoverflow.com/questions/12284090/no-branch-when-installing-with-composer-json 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: https://github.com/composer/composer/issues/1164 Maybe they reverted it.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.