Skip to content

Links to commits in git subscriptions #3814

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

Open
3 tasks done
BenHesketh21 opened this issue Apr 8, 2025 · 8 comments · May be fixed by #3870
Open
3 tasks done

Links to commits in git subscriptions #3814

BenHesketh21 opened this issue Apr 8, 2025 · 8 comments · May be fixed by #3870

Comments

@BenHesketh21
Copy link
Contributor

BenHesketh21 commented Apr 8, 2025

Checklist

  • I've searched the issue queue to verify this is not a duplicate feature request.
  • I've pasted the output of kargo version, if applicable.
  • I've pasted logs, if applicable.

Proposed Feature

This may be a setting I can't find or something but we should be able to click through to the commit on Github/Gitlab for Git subscription types, after using the OCI annotations for container subscriptions (which is super useful) this feels like a nice addition.

Motivation

It would allow a user to click through and see the commit that the Freight is referring to.

Suggested Implementation

Build the URL the same way the UI does from the OCI annotations using the RepoURL and commit ID in the freight.
Or for a more future proof way (if/when more git providers come along), add a field to the subscriptions that is like the Github Autolink feature so they would need to add something like:

  - git:
      repoURL: https://github.com/some-org/some-repo
      linkPathFormat: /commit/{{ id }}
      strictSemvers: false
      discoveryLimit: 10
@krancour
Copy link
Member

This is a good idea, but idk if I'd address it in this way. In general, we want more (much more) traceability from Kargo back to PRs, commits, diffs, etc., and there are quite a number of issues open relating to that. I think the best UX here, probably, is to improve the various implementations of gitprovider.Interface with an intrinsic understanding of how to construct various sorts of URLs for their given platform. I'd much prefer Kargo just knowing how to do that than having to specify linkPathFormat in every Warehouse.

@BenHesketh21
Copy link
Contributor Author

Makes sense, so would each interface have to support links to commits and Pull Requests? Or are Pull requests links already supported as part of the PR promotion steps?

@krancour
Copy link
Member

Yes. The interfaces would need to be expanded with methods that construct these URLs. For any PR URLs that are currently constructed, it's happening way down the stack in the libraries that the provider implementations use to talk to their corresponding services.

@BenHesketh21
Copy link
Contributor Author

I'd be happy to take this and give it a go

@krancour
Copy link
Member

Thanks @BenHesketh21! That would be much appreciated!

I think adding the relevant methods to each provider will end up being the easy part. Actually surfacing that information in a meaningful way is something I haven't even thought about yet. My initial thought is that this is could be surfaced in the output from the commit step, but I really haven't thought that all the way through yet. Feel free to hit me up to discuss that aspect of this further.

I'll also volunteer @Marvin9 in case you need any guidance on how to then surface these new details in the UI. I myself am no good with UI stuff. 😂

@Marvin9
Copy link
Contributor

Marvin9 commented Apr 11, 2025

This will be covered as part of revamping freight timeline and overall pipeline view

@BenHesketh21
Copy link
Contributor Author

@krancour I'm making a start on this now and I can see that the URL for a pull request is already returned from the GetPullRequest, ListPullRequests and CreatePullRequest methods in the gitprovider.interface. With the view of being consistent should we add a GetCommit method that passes on the SHA, commit message and URL back from the hosting provider? Or do you still there is value on methods that accept a repoURL and sha (or PR number) and just build the URL?

@krancour
Copy link
Member

@BenHesketh21 great question, and it's leading me to clarify something I wasn't previously consciously aware of enough to have mentioned... but which you may already have figured out...

Don't assume there's any pull request involved here. There may not have been. Writes back to a Git repo, especially in non-prod environments, are often just a push directly to some branch.

So while the providers are currently used only to facilitate opening and checking the status of pull requests, I think we're talking about entirely new use for them here.

A method named something like GetCommitURL() or BuildCommitURL() seems it would be appropriate. It would use provider-specific knowledge to construct the URL as a function of two arguments -- repo URL and commit ID.

Actually surfacing that information in a meaningful way is something I haven't even thought about yet. My initial thought is that this is could be surfaced in the output from the commit step, but I really haven't thought that all the way through yet.

Having thought about this more now, it should be output of the push step, because unless/until a commit is pushed to the remote repository, any URL we build would yield a 404 when requested.

@krancour krancour modified the milestones: v1.5.0, v1.6.0 Apr 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants