dirk-thomas / vcstool

Vcstool is a command line tool designed to make working with multiple repositories easier
Apache License 2.0
419 stars 89 forks source link

deleting code that is no longer defined in the repos #228

Open LukeAI opened 3 years ago

LukeAI commented 3 years ago

say I have a myrepos.repos file that is imported by a workspace setup script like: vcs import < repos/myrepos.repos

myrepos.repos is in version control and contains a set of repos that changes over time, sometimes repos are added and sometimes taken away.

Currently, if a repo is deleted from myrepos.repos - the previously cloned subrepo persists. Is there some supported way I can have vcstool automatically delete everything that is not defined in myrepos.repos?

I could simply rm -rf src before running vcs import but unfortunately downloading is expensive as there are a number of very large (LFS) files in the repos.

piotr-zyskowski-rai commented 1 year ago

I was looking for this feature inside of the vcstool. Is there a plan to make it available?

Or at least to have a command allowing users to explicitly request a warning that a repository is present when they call vcs import (this issue seems to be similar to such functionality). If the system is big, dynamic, and relies heavily on vcs tool - like autoware - it is quite difficult to keep track of changing repositories without such a feature.

Ryanf55 commented 8 months ago

This is a problem in gitlab CI with the default git strategy. Clones in CI get polluted with old repos, and there isn't a way to clean it out. https://docs.gitlab.com/ee/ci/pipelines/settings.html#choose-the-default-git-strategy

If you take care of using a good .gitignore that matches the repos file, then you could try cleaning out the local git directory after checkout.

Ryanf55 commented 8 months ago

Wow, this workflow is also broken when a fetch git strategy.

  1. Have a .repos file that has a repo on branch branchA
repositories:
   my/repo1:
      type: git
      url: git@github.com:my/repo1.git
      version: branchA
  1. Commit a change to the .repos file where you switch branches to branchB
repositories:
   my/repo1:
      type: git
      url: git@github.com:my/repo1.git
      version: branchB

And, the CI checkout script is as follows:

vcs import --input my_sources.repos src --debug --force --shallow
vcs pull src
vcs status src

The import and pull succeeds, but vcs status still shows my/repo1 is at branchA. We have a mix of local repositories and cloned reposities in the src workspace. Being able to clear out the src directory and use VCS to check out the correct branch when using fetch strategy for the top workspace would be extremely helpful to keep CI fast.

For now, we will have to change to a pull strategy and do a lot of I/O in jobs.