your-tools / tsrc

Manage groups of git repositories
https://your-tools.github.io/tsrc/
BSD 3-Clause "New" or "Revised" License
206 stars 36 forks source link

Documentation concerning tsrc apply-manifest #336

Open Lecrapouille opened 2 years ago

Lecrapouille commented 2 years ago

Environment

Hi ! Close question to this topic https://github.com/dmerejkowsky/tsrc/issues/279

The documentation could be updated to clarify the following incertitude. I was questioning myself concerning https://dmerejkowsky.github.io/tsrc/guide/manifest/ with sections "Using the apply-manifest command to avoid breaking developers' workflow" and "Additional notes".

Is:

It is common to place the manifest repo itself in the manifest - so it's easy to edit or read

(described in Additional notes)

Compatible with this command:

cd /path/to/work # holding .tsrc refering to manifest/manifest.yml
tsrc apply-manifest manifest/manifest.yml

? (described in Using the apply-manifest command to avoid breaking developers' workflow

In other way: is the command tsrc apply-manifest works fine when the git repository holding the manifest is inside the workspace installed by tsrc init ?

The answer seems to be yes, but this is not obvious because manifest/manifest.yml is dirty iand it will update .tsrc/xxx/manifest.yml which will try to update manifest/manifest.yml (but since dirty tsrc will not try to update ... or failed).

I tried two things:

dmerejkowsky commented 2 years ago

The workflow looks like this. Say you want to add a new repo, named bar and you already have:

repos:
  - url: git@github.com:dmerejkowsky/foo.git
    dest: foo

  - url: git@github.com:dmerejkowsky/dummy-manifest.git
    dest: manifest
  1. Run tsrc init so that 'foo' and 'manifest' are cloned in their respective folders
  2. Edit the file in<workspace>/manifest/manifest.yml to add the new repo:
  - url: git@github.com:dmerejkowsky/foo.git
    dest: foo
+
+  - url: git@github.com:dmerejkowsky/bar.git
+    dest: bar
  1. Run tsrc apply-manifest <workspace/manifest/manifest.yml to make sure your changes are correct
  2. Create a commit with your changes in the manifest repo
  3. Push the commit into a branch in the manifest, say add-bar
  4. Make someone review the changes
  5. Merge the add-bar branch into the master branch of the manifest
  6. Run tsrc sync.
  7. The repo in .tsc/manifest is updated
  8. Since 'bar' was already cloned when you ran apply-manifest no new repo is cloned
  9. The repo in manifest/manifest is not updated because it's on the branch add-bar and it should be on master
  10. You can then manually run cd <workspace>/manifest ; git checkout master

tsrc did not switch to the branch to master. Not sure why !

That's expected. See the relevant documentation

Lecrapouille commented 2 years ago

@dmerejkowsky thank you for confirming that we can call apply-manifest inside the workspace but not necessary have to be applied from a manifest outside the workspace. The documentation was unclear on this point and you should include your example to remove any confusion.

Sorry for my poor English. In fact, I wanted to say that I tried two different things:

First thing:

Inital workspace/manifest/manifest.yml:

repos:
  - url: git@github.com:dmerejkowsky/foo.git
    dest: foo

If I add a new repo bar:

repos:
  - url: git@github.com:dmerejkowsky/foo.git
    dest: foo

  - url: git@github.com:dmerejkowsky/bar.git
    dest: bar

The command tsrc apply-manifest workspace/manifest/manifest.yml will git clone the bar/ repo.

Ok so far so good :) but :

Second thing:

Inital workspace/manifest/manifest.yml. Initial repo (repo foo with branch dev-foo):

repos:
  - url: git@github.com:dmerejkowsky/foo.git
    branch: dev-foo
    dest: foo

Change the branch of repo foo to follow master:

repos:
  - url: git@github.com:dmerejkowsky/foo.git
    dest: foo

The foo repo is not dirty ! Even if I commit (or not) workspace/manifest/manifest.yml in local (your step 3.) when I call tsrc apply-manifest workspace/manifest/manifest.yml the branch is not switched. Do you consider that I'm on the case described by your documentation in case the repository is on an incorrect branch, the fast-forward merge will still be attempted, but an error message will be show in the end because tsrc does not print error (echo $? is 0) and there is no possible conflict because the repo is clean and the switch to the branch is possible (git checkout works). But it stays to the dev-foo branch.