Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

graphqlbackend: Add changelistURL to GitBlob#53605

Merged
indradhanush merged 2 commits intomainfrom
ig/filenode-changelisturl
Jun 16, 2023
Merged

graphqlbackend: Add changelistURL to GitBlob#53605
indradhanush merged 2 commits intomainfrom
ig/filenode-changelisturl

Conversation

@indradhanush
Copy link
Contributor

@indradhanush indradhanush commented Jun 16, 2023

Part of #40330.

Why

We want to be able to generate permalinks for files in a perforce depot

What

  • Add the changelistURL property to the File2 interface
  • Add the changelistURL property to all the types that implement the File2 interface
  • Implement the ChangelistURL API and return a changelist URL for the GitBlob type
  • Return nil for all the other types that implement File2 (existing behaviour for these types, for example url is also not implemented on them)

Following existing conventions. Ideally we should have a top level urls node that embeds all the different type of urls instead of having them on the top level definition in the File2 interface, but that is a major API change that we're not ready for

Test plan

  • Added tests
  • Tested with UI code (another PR coming soon)

@cla-bot cla-bot bot added the cla-signed label Jun 16, 2023
@indradhanush indradhanush requested review from a team and peterguy June 16, 2023 15:41
@indradhanush indradhanush self-assigned this Jun 16, 2023
@indradhanush indradhanush added perforce graphqlbackend perforce-changelists Issues around Changelist Ids for Perforce depots labels Jun 16, 2023
@sourcegraph-bot
Copy link
Contributor

Codenotify: Notifying subscribers in CODENOTIFY files for diff 5089e69...6379006.

Notify File(s)
@courier-new cmd/frontend/graphqlbackend/batches.go
@eseliger cmd/frontend/graphqlbackend/batches.go

@sourcegraph-bot
Copy link
Contributor

📖 Storybook live preview

Copy link
Contributor

@sashaostrikov sashaostrikov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

}

func (r *GitTreeEntryResolver) ChangelistURL(ctx context.Context) (*string, error) {
repo := r.Repository()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a sanity check: we won't fetch repo here for the second/n-th time, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope. It returns the r.commit.repoResolver which is already set as a backlink in the GitTreeEntryResolver which is set when the resolver is initialised.

Good check though!

}

func (r *PerforceChangelistResolver) cidURL() *url.URL {
// Do not mutate the URL on the RepoMatch object.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment may be misleading since RepoMatch doesn't contain the URL itself, it is constructed from other properties and returned as a new object which we can totally mutate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah - I agree. I will fix in a follow up. Going ahead with the merge because branch cut in ~8 mins. :P

@indradhanush indradhanush merged commit 0f95405 into main Jun 16, 2023
@indradhanush indradhanush deleted the ig/filenode-changelisturl branch June 16, 2023 16:53
coury-clark pushed a commit that referenced this pull request Jun 21, 2023
…st view page (#53668)

Stacked on #53605. 

Part of #40330.


## Test plan

🎥
https://www.loom.com/share/a516e86ffc4341f7a7bfd83c1808c7bd?sid=d6d1d5fe-5842-458e-8078-4fb3d4e9d0c1

<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->
 <br> Backport 65345a7 from #53608

Co-authored-by: Indradhanush Gupta <indradhanush.gupta@gmail.com>
ErikaRS pushed a commit that referenced this pull request Jun 22, 2023
Part of #40330.

## Why

We want to be able to generate permalinks for files in a perforce depot

## What

- Add the `changelistURL` property to the `File2` interface
- Add the `changelistURL` property to all the types that implement the
`File2` interface
- Implement the `ChangelistURL` API and return a changelist URL for the
`GitBlob` type
- Return nil for all the other types that implement `File2` (existing
behaviour for these types, for example `url` is also not implemented on
them)

Following existing conventions. Ideally we should have a top level
`urls` node that embeds all the different type of urls instead of having
them on the top level definition in the `File2` interface, but that is a
major API change that we're not ready for
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla-signed perforce perforce-changelists Issues around Changelist Ids for Perforce depots

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants