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

chore(codenav): Resolve repo and commit in common code#63072

Merged
varungandhi-src merged 11 commits into
mainfrom
vg/resolve-args
Jun 7, 2024
Merged

chore(codenav): Resolve repo and commit in common code#63072
varungandhi-src merged 11 commits into
mainfrom
vg/resolve-args

Conversation

@varungandhi-src

@varungandhi-src varungandhi-src commented Jun 4, 2024

Copy link
Copy Markdown
Contributor

This PR replaces https://github.com/sourcegraph/sourcegraph/pull/63057. We introduce
a new type which carries information about the repo, the deserialized cursor etc.

Test plan

Added some property based tests to check that the function doesn't panic
on different kinds of inputs.

Changelog

@cla-bot cla-bot Bot added the cla-signed label Jun 4, 2024
@github-actions github-actions Bot added team/graph Graph Team (previously Code Intel/Language Tools/Language Platform) team/product-platform labels Jun 4, 2024

@kritzcreek kritzcreek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Very, very nice. Thank you for doing this.

Comment thread internal/codeintel/codenav/transport/graphql/root_resolver.go Outdated
Comment thread internal/codeintel/resolvers/codenav.go Outdated
Comment thread internal/codeintel/resolvers/codenav.go Outdated
@github-actions

github-actions Bot commented Jun 5, 2024

Copy link
Copy Markdown
Contributor

Caution

License checking failed, please read: how to deal with third parties licensing.

@github-actions

github-actions Bot commented Jun 5, 2024

Copy link
Copy Markdown
Contributor

Caution

License checking failed, please read: how to deal with third parties licensing.

Comment thread internal/codeintel/resolvers/codenav.go Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This missing initialization before setting a field later was caught by rapid. 🎉

Comment on lines 192 to 197

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not exactly sure what this is, I'll try to minimize it later.

Comment thread internal/pbt/probability_test.go Outdated
Comment on lines 22 to 23

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@kritzcreek I thought we should have a basic test for this generator, not sure how you feel about this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It don't mind the test as a usage example (it's cute), but it doesn't increase my confidence in the Bool implementation much.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I removed this and added a Pearson's Chi-Squared test for WithProbabilities instead.

Comment thread internal/codeintel/resolvers/codenav.go Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I know this might seem a bit overkill, but I figured since we need the recursive traversal anyway, adding a cache is not that much extra work.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, adding the cache seems fine even if we can't produce a filter with more than one repository reference for now. Finally I can filter my usages for (not (not (not (not "github.com/sourcegraph/sourcegraph"))))

@kritzcreek kritzcreek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code looks good in general. Added a few smaller nits, but nothing that should block you from merging once you've fixed the entropy crash

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

WDYT about shadowing the args variable here so we don't accidentally use the unresolved version further down.

@varungandhi-src varungandhi-src Jun 7, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The scoping in Go doesn't match Rust/ML, so that would be an error since the type would change. It would require introducing another function (or a block). However, I can change the variable names so that this is args and the other one is unresolvedArgs, so the latter becomes more inconvenient to type.

Comment thread internal/pbt/probability.go Outdated
Comment thread internal/pbt/probability_test.go Outdated
Comment on lines 22 to 23

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It don't mind the test as a usage example (it's cute), but it doesn't increase my confidence in the Bool implementation much.

Comment thread internal/pbt/probability.go Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The correct way to check the sign of a float would be to math.Copysign(1, p.Chance) < 0

@varungandhi-src varungandhi-src Jun 7, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm guessing this is for the -0.0 case? I think it doesn't matter if it is -0.0 here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, probably doesn't matter here. Just thought it might be an interesting bit of trivia

Comment thread internal/codeintel/resolvers/codenav.go Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, adding the cache seems fine even if we can't produce a filter with more than one repository reference for now. Finally I can filter my usages for (not (not (not (not "github.com/sourcegraph/sourcegraph"))))

@varungandhi-src varungandhi-src changed the title chore(codeintel): Resolve repo and commit in common code chore(codenav): Resolve repo and commit in common code Jun 7, 2024
@varungandhi-src varungandhi-src merged commit 1284536 into main Jun 7, 2024
@varungandhi-src varungandhi-src deleted the vg/resolve-args branch June 7, 2024 13:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla-signed team/graph Graph Team (previously Code Intel/Language Tools/Language Platform) team/product-platform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants