carvel-dev / vendir

Easy way to vendor portions of git repos, github releases, helm charts, docker image contents, etc. declaratively
https://carvel.dev/vendir
Apache License 2.0
268 stars 46 forks source link

A 'dev' mode to preserve local changes in git/hg repositories #388

Open cdevienne opened 1 week ago

cdevienne commented 1 week ago

Describe the problem/challenge you have

We use vendir in meta-projects, and work directly in the git/hg synced sub-repositories. After doing some changes in them, we cannot do a "vendir sync" without loosing local changes (and lazy doesn't work if we pull some ref changes). Also, after commit & pushing changes in the sub-repositories, we would like to automatically update the vendir configuration file with the current commit id/tag of each repo.

Describe the solution you'd like

We think vendir could benefit from a "dev" mode, which would be enabled by using a "dev-sync" command or a "--dev" switch on the sync command.

When turned on, vendir would change its sync behavior for mercurial and git (at least) in the following way:

A new command "dev-baseline" (for example) would, for each vcs directory, determine what the current ref is:

Anything else you would like to add:

The overall experience is inspired by the "hg-confman" mercurial extension that we intend to replace with vendir.

We are willing to work on an implementation for these features, and would like your opinion before diving into coding.

praveenrewar commented 4 days ago

We use vendir in meta-projects, and work directly in the git/hg synced sub-repositories.

@cdevienne Could you through some more light on this use case. vendir is used to pull config from a source. It seems like you also want to make changes in the same config and then be able to pull more changes from the source, which would make vendir work on two different source of truths. Also, it would require vendir to do things like merging the config from source and local. cc @joaopapereira

cdevienne commented 4 days ago

One of our use cases is the following: we have repositories for odoo modules, that we sync in a top-level client project. When working on the client project, the developer updates some code in synced sub-repo(s), runs some tests locally and when satisfied commit changes in both the synced sub-repo(s) and the top-level repo.

When working a sub-repo, there is a period of time where the synced directory is not in-sync. So not really 2 sources of truth, just a gray area, until one those 2 events happen:

We can already do this with vendir but it requires to be very careful if we don't want to lose any local change because 'sync' will drop everything and start over.

The changes we suggest in "vendir sync" provide safety for the local changes, and would work a little like the "--lazy" option but safer. So no added need for merging configurations.

And the "dev-baseline" command is to make the vendir configuration update easier.