Skip to content

Conversation

spog
Copy link
Contributor

@spog spog commented Sep 17, 2025

Current implementation already allows for specifying explicit commits like '-b commit' to pin subrepo sources (i.e during subrepo clone/pull). In that case, it also sets the name of the branch in the subrepo merge commit message and inside .gitrepo file to that commit hash. This addition allows for specifying both branch and commit. During the subrepo fetch phase, the commit is checked against the specified branch. If the requested commit can be reached from the head of the requested branch, the subrepo is re-fetched to that commit.
Afterwards command processing remains the same, except that given branch name is written to the subrepo clone/pull commit message and into the .gitrepo file.
The commit part of the '-b branch@commit' request may be abbreviated to the reasonable extent.

Current implementation already allows for specifying explicit commits
like '-b commit' to pin subrepo sources (i.e during subrepo clone/pull).
In that case, it also sets the name of the branch in the subrepo merge
commit message and inside .gitrepo file to that commit hash.
This addition allows for specifying both branch and commit. During the
subrepo fetch phase, the commit is checked against the specified branch.
If the requested commit can be reached from the head of the requested
branch, the subrepo is re-fetched to that commit.
Afterwards command processing remains the same, except that given
branch name is written to the subrepo clone/pull commit message and
into the .gitrepo file.
The commit part of the '-b branch@commit' request may be abbreviated to
the reasonable extent.
@admorgan
Copy link
Collaborator

Would you be willing to add tests for this?

@spog
Copy link
Contributor Author

spog commented Sep 17, 2025

I could try - it'll take a while. What would be the essential test scenario(s) in your opinion?

@admorgan
Copy link
Collaborator

Off the top of my head:

  1. In repo bar create a branch and add multiple commits
  2. In foo clone bar with you new commands
  3. In foo make a change to the content of bar
  4. In foo subrepo push bar
    • Should fail
  5. In foo subrepo pull bar
  6. In foo subreopo push bar
  7. In foo subrepo pull bar@older SHA
    • Should fail

I am probably missing some variations, but that is a good start.

@spog
Copy link
Contributor Author

spog commented Sep 17, 2025

Thanks for the suggestion.

When branch@commit is requested in clone, fetch and pull commands,
show that in their output as well.
It does the following:
1. Clone default test repos foo and bar
2. Create a new branch bar1 in bar
3. In bar create three additional commits in bar1
4. Checkout default branch in bar (to allow for later push)
5. In foo subrepo clone of bar1@commit1 from bar
6. Test clone results
7. In foo subrepo pull of bar1@commit2 from bar
8. Test pull results
9. Make additional change in foo/bar
10. In foo subrepo push bar and test result (push fails)
11. In foo force subrepo clone bar@commit3 (last commit in bar1)
12. Re-make additional change in foo/bar
13. In foo subrepo push bar and test result (push success)
13. In foo subrepo pull bar1 from bar and test result (up to date)
14. In foo subrepo pull bar1@commit2 (fails - old commit)
15. In foo subrepo clone bar1@commit2 (fails - subrepo exists)
@spog
Copy link
Contributor Author

spog commented Sep 21, 2025

Hi, i prepared initial tests for using branch@commit. I tried to follow your test scenario suggestions:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants