-
Notifications
You must be signed in to change notification settings - Fork 4
Fix keepalive in forks #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
webstech
merged 2 commits into
gitgitgadget:main
from
gitgitgadget-workflows:fix-keepalive-in-forks
Sep 8, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First, can this be done through the checkout action?
Second, the next line fetches from the upstream which may contain new updates that are not the keep alive. Would this possibly pull in changes unexpectedly? Sorry if I have misunderstood.
Would it work to just have the keep alive on a separate branch that never gets merged?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the
checkout
step could get something like:Honestly, I find the
--unshallow
approach more obvious.And yes, this can drag in new upstream changes. But isn't that a good thing? Relying on
gitgitgadget/gitgitgadget@v1
shares that trait...It might count as activity if a branch different than the main branch is pushed. The documentation is not terribly clear about that. Judging by the fact that workflow dispatches do not count as activity, I seriously doubt it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I was going to suggest only doing the unshallow if a merge is needed. More steps but the unshallow will slowly get bigger over time so only doing if necessary could help.
I can see confusion when anyone (especially for non-git users of ggg) makes a config change and finds out a merge (or rebase) is needed due to keep alive being pushed.
Not running workflows due to no activity has a purpose. On the other hand there can be workflows that would create activity based on external data the workflow examined. This case is more unusual since the workflows are running to handle activity in other repos.
Just thinking about order of execution where the fork could consistently run before the upstream. It would create a commit and then do a merge the next time it ran to pull in the upstream keepalive commit. What if the commit was only done with the upstream and the fork merges if there are local changes and pushes the upstream changes to the fork. Still trying to this clear in my head.
I am okay with implementing this as is. I am just concerned there could be unexpected merging (fork has keep alive but we want to pull updates from upstream without waiting).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The unshallow is needed to determine whether a merge is needed :-)
Actually, we could use the
repos/.../compare
GitHub REST API endpoint which reportsahead_by
/behind_by
numbers. That could also inform the workflow about how much the depth has to be increased.But that feels utterly over-engineered.
How about simply using
depth: 150
always, no matter whether in a fork or not? That should be good enough for merging, be reasonably fast, and first and foremost: simple.Right. And it is worth mentioning that when you fork, the
keepalive
workflow is disabled by default, thanks to being a scheduled workflow.And yes, the ideal case is a fast-forward in
keepalive
, and I do want to encourage that forks keep their changes in a shape that they can be upstreamed so that eventually they are in sync with upstream again (as in: identical tip commit).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If HEAD does not match FETCH_HEAD a merge is needed. Which is really refs/head/main compared to FETCH_HEAD. BUT the upstream fetch is not going to be limited if HEAD is not part of the upstream history. Just thinking out loud convincing myself the unshallow is needed (either explicitly or through the checkout).
I think we can go with the current setup for now (KISS). If there is no extra activity, it could be years before that depth is reached.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
HEAD
does not matchFETCH_HEAD
, it is possible that a merge cannot be done becauseFETCH_HEAD
(in this diagram,main
) is an ancestor ofHEAD
(in this diagram,downstream
). But an unshallow is needed to be able to determine that, otherwiseHEAD^
won't be present and the revision walk will end there, claiming unrelated histories (which is what happened in my fork, triggering my work on this here PR 😉).