Depend on a specific Branch of a Dependency

Motivation:
We were thinking about breaking up our application in smaller parts. However we have stopped the project due to this missing Feature/we couldn’t figure it out anyway.

Explanation of the problem
Lets say:
B → depends on A
C → depends on A

Now lets say dev1 builds a feature for B and dev2 builds a feature for C.
Both need to make small changes to A as well.

When working with dependencies you currently have two choices:

  1. Depend on a specific Version
  2. Depend on Published / Development

No. 1 Is a pain because they would need to make a lot of small versions and change them in the dependecy a lot.
No. 2 Does not work for more developers.

Possible Solution
Make it possible to depend on a specific branch of the dependency.
This way it would be possible to develop a features by creating a feature branch in both apps, and after development merging it into the master.

If there are other workflows for developing dependencies with more than 4 developers.

Thanks

Mark

3 Likes

I currently work around this by having a development copy of a dependency app. I can then use its master and published branches in the way you describe.

I use a singe local clone of the repo for the app. When I merge changes that are ready for production, I then push those to the production copy of the app.

e.g. for anvil-extras, I have two copies at anvil.works - one that is the production copy with the id that anyone can use, the other called ‘Anvil Extras Dev’ that only I can see. If I’m working on some new feature, I’ll test that using an app with the master branch of the dev copy as a dependency.

My local copy of the repo has three remotes - production, dev and github - we actually use a github action to push changes to production as and when we merge to main.

Elsewhere, for a larger team, we work in a similar fashion. Each of us has our own dev copy of the app we work on and we do our thing in there, sending pull requests to github when we’re ready. Amoni was built with this in mind to avoid even needing the dev copy at anvil and, instead, working entirely locally.

I would probably continue to work this way even if your request was implemented. It isolates the production copy nicely and reduces the risk of developers inadvertently making changes in the wrong place.

4 Likes

Hi @owen.campbell,

thanks for the workaround tipp, especially with github actions + amonia this seems to be a proper way to go! Provided, all your team members can properly use git - which at least in my experience is not always the case.

Still - I think as soon as Anvil will be used by larger Teams this feature will be a very nice addition.
But I agree that it is not as isolated as a local copy. Maybe this feature needs to come along with pull requests / branch protection to fully bring it to life.

Interesting. I regard git as core knowledge for anyone calling themselves a developer. I wouldn’t let anyone who didn’t know how to use it anywhere near the code base for anything other than personal hobby projects.

You can depend on specific version tags in the git repository. It’s not by branch, but it might provide a reasonable workaround.

You have to clone the repo to your local machine to create the tags, and push it back so Anvil recognizes them, but that gives you additional dependency points besides Production and Development.

2 Likes

3 posts were split to a new topic: How to depend on a tag

As I’ve been breaking a single monolithic app into an app and a dependency with the new editor’s environments, I wanted to include a more recent vote for this feature of being able to depend on a specific branch of a dependency.

In the current system you can depend on:

  1. The master branch, by choosing to depend on the Development version of the app
  2. The published branch, by choosing to depend on the Published version of the app
  3. A specific vX.Y version tag (this is great for locking in a set of features that won’t change unexpectedly)

The way I have my apps setup is to have a development branch for development, the master branch for testing, and the published branch for deployment. I’d like those environments to depend on the appropriate branch in the dependency (e.g. development, master, published) so each environment is working with the matching on in the dependency.

At the moment I can only get two out of the three matching up. One branch, either the development or testing branch, ends up not being able to be targeted without using version tags.

Being able to depend on specific branches would solve this issue and give developers a lot more flexibility in how they setup their branches/environments.

1 Like

Hi all,

Thanks for chasing this. It is on our list.

2 Likes