You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
✨ Add remote fetching (tags, branches) to Git functionality #10200
I'm running source.AsGit().WithAuthToken().Tags(ctx) and realized it won't show the remote tags because it doesn't do a fetch. Would it be possible to add a AsGit().Fetch(branch or all)?
Why is this important to you?
The AsGit is very useful but I can't use it because I need to fetch before doing much with the repo. The fetch itself requires a PAT so I have to set up all of that whereas AsGit().WithAuthToken() handles it.
How are you currently working around this?
Setting up all the plumbing necessary inside the container like this #9858
I like source.AsGit().Remote("origin").Tags(), which would then look up "origin" in the target repository, which would then be the remote "origin", and return it as another GitRepository.
A couple little notes:
Where do the auths go? I'm kind of leaning towards putting them as args to Remote which mirrors how the args in the git top-level constructor work. I think being able to do WithAuthToken on a result from AsGit is a bit of an anti-pattern, since an auth token isn't used for a directory here (so I'd like to deprecated those).
Remote naming becomes pretty important. e.g. origin/upstream/etc - users might name these differently - is that an issue?
Hm, just realized that it's really not possible to implement this for remote git providers - it's only valid for local git: Directory.asGit.remote is valid, git.remote isn't.
It would be really cool if we could somehow have it follow fork/upstream relationships, but there's no way to get this generically from the Git API - we'd have to implement provider-specific integrations (which I was hoping to avoid, since it's a pain).
Activity
jedevc commentedon Apr 22, 2025
Mm, very reasonable, I've also wanted this.
I like
source.AsGit().Remote("origin").Tags(), which would then look up"origin"in the target repository, which would then be the remote "origin", and return it as anotherGitRepository.A couple little notes:
Remotewhich mirrors how the args in thegittop-level constructor work. I think being able to doWithAuthTokenon a result fromAsGitis a bit of an anti-pattern, since an auth token isn't used for a directory here (so I'd like to deprecated those).origin/upstream/etc - users might name these differently - is that an issue?shykes commentedon Apr 23, 2025
@jedevc would the host's auth be loaded implicitly by default? PAT etc?
jedevc commentedon Apr 24, 2025
Likely, yes, just as if you were to do
dag.Git("url").I think that makes the most sense (and probably easiest to implement in terms of behavior).
Edit: actually, we should probably do in this order:
WithAuthToken/WithAuthHeadermethods)jedevc commentedon May 15, 2025
Hm, just realized that it's really not possible to implement this for remote git providers - it's only valid for local git:
Directory.asGit.remoteis valid,git.remoteisn't.It would be really cool if we could somehow have it follow fork/upstream relationships, but there's no way to get this generically from the Git API - we'd have to implement provider-specific integrations (which I was hoping to avoid, since it's a pain).
jedevc commentedon Jul 31, 2025
Authentication aside, I ran into a super concrete thing we need in our own CI.
If I specify a high
--depth, and the local directory fordir.asGitis a shallow clone, we should fallback to fetching any history from the remotes.