Commit Graph

115 Commits

Author SHA1 Message Date
Michael Bahr
4d6e8949e8
fix(batches): don't request unnecessary info that's likely to cause GH errors (#64299)
Closes SRCH-802

After a long and unsuccessful hunt of eventual consistency errors, I
noticed that we don't need the GraphQL fragments that are causing
problems.

I introduced a simplified request, which succeeds reliably. What
customers should see now is one error (see second picture below), which
is followed by a retry, and then success.

Previously we've seen this error, sometimes less often, sometimes more,
but customers saw it so often that it caused their batch changes to
fail.

<img width="1042" alt="Screenshot 2024-08-06 at 14 02 00"
src="https://github.com/user-attachments/assets/c5a099da-d474-43db-ac12-ac7c4f22d4d3">

Customers may still see an initial error, which I've seen to reliably
disappear on the first retry. It should not be a problem

<img width="1039" alt="Screenshot 2024-08-06 at 14 02 48"
src="https://github.com/user-attachments/assets/99f278d4-4020-48ea-b4ac-32cbdfce455d">

## Test plan

Manual testing

## Changelog

- fix(batches): improve GitHub Apps integration reliability by
simplifying the data requested from GitHub
2024-08-07 10:47:37 +02:00
Erik Seliger
c917330d6b
authz: Drop requirement for installing authz providers in every service (#63743)
This is a register call that is easy to forget. When forgotten, all queries against the repo store will block forever.

In addition, this adds a hard-dependency on conf to every services startup, plus a busy loop. With multi-tenant, this will not work great because authz providers would be a global, and we instead want most things to be ephemeral so they're per-provider. This is a step toward that, but doesn't yet remove the providers global variable.

Good news, it turns out that we don't actually need to register the providers in every service! The reason they were required was to check if zero providers are configured, or if authzbypass mode is enabled.

Authz bypass mode is usually ON, except when there are problems with the authz providers, meaning some authz providers might not be able to sync permissions. Bypassing of permissions is only ever happening if there are ALSO zero providers configured.

So this is basically an optimization for the case where an instance has zero authz configured so that the SQL queries are a bit simpler. This also helps in tests because with bypass mode on and no providers configured, authz enforcement is effectively off in the repo store.
This makes it so that in tests we need to do slightly more work, but also makes for a more realistic test vs at runtime setup. Also, it's highly recommended to use mocks for DB wherever possible in more high-level components to keep tests fast.

To never have a scenario where we accidentally mess up here and enable bypass mode erroneously, this PR drops that entirely. Authz is always enforced, but when a code host connection is unrestricted (i.e., will not spawn a provider) the repos are still visible, so this should be no change over before.

## Test plan

The stack starts and works, and all CI tests are still passing. Code review should help as well.
2024-07-31 01:23:34 +02:00
Michael Bahr
3ff0ddf1cb
fix(batches): switch github app installation handling from redirect flow to webhooks (#64036)
Closes SRCH-741
Closes SRCH-716

This PR removes the GitHub installation code from the redirect flow to a
webhook-based appraoch. We expect that the GitHub server calls the
webhook when the installation is ready, and therefore shouldn't see the
errors explained in the issues above.

To handle the potential delay until the webhook is called and the
credential is set up, I added a scrappy info notice that the user should
refresh their page:

<img width="928" alt="Screenshot 2024-07-24 at 13 48 24"
src="https://github.com/user-attachments/assets/4d298f2a-d7b8-423b-9e2f-2ae53fbce1ac">

Below is what you see after you refreshed (or if the webhook was called
faster than the user being redirected back to the settings):

<img width="929" alt="Screenshot 2024-07-24 at 13 50 14"
src="https://github.com/user-attachments/assets/b6826158-8561-476d-b20e-e36f8cfb86fd">

I'm able to create PRs for sourcegraph-testing with an app that was
created this way.

<img width="1171" alt="Screenshot 2024-07-24 at 16 16 06"
src="https://github.com/user-attachments/assets/86e20acb-136f-4a46-a33b-bdfdd0d51d71">

I'm seeing an error when getting an access token with a personal github
app to run a batch change, but that will be handled with another PR.

<img width="1053" alt="Screenshot 2024-07-24 at 16 38 38"
src="https://github.com/user-attachments/assets/5655ba91-1ae4-453a-8d5c-1bcdbe34bc17">

## Test plan

Manual testing locally, and more testing to be done on S2 where we have
a more production like environment

## Changelog

- When installing a GitHub app for batch changes, the instance now waits
for a callback from GitHub to complete the installation to avoid issues
from eventual consistency.

---------

Co-authored-by: Peter Guy <peter.guy@sourcegraph.com>
2024-07-26 11:53:34 +00:00
Petri-Johan Last
64ac259ab5
[fix] Fix being unable to add batch changes credentials when rate limited (#63984) 2024-07-26 11:07:59 +02:00
Erik Seliger
175667db7c
gitserver: Add OctopusMergeBase RPC method (#63842)
This method can be used to find a common ancestor for many commit SHAs,
to be used by code intel for finding visible uploads.

Closes SRC-485

Test plan: Added unit tests for the several layers (client, grpc,
gitcli).
2024-07-19 13:25:09 +02:00
Erik Seliger
a0a18a60e9
gating: Add individual switches for disabling tools features (#63686)
This PR adds better gating for disabling the code monitors, notebooks,
search jobs and own features.

## Test plan

Ran locally and verified the features are gone when the env var is set.
Ran again without those and they worked.

---------

Co-authored-by: Stefan Hengl <stefan@sourcegraph.com>
2024-07-16 15:45:38 +02:00
Bolaji Olajide
43f907f8a9
fix(batches): enable check for creating source as non credential (#63751)
This check was wrong as we create a non-credential source only when the
ChangesetSource strategy isn't `GitHubApp`

## Test plan

<!-- REQUIRED; info at
https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles
-->
Manual testing

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
2024-07-10 13:58:13 +00:00
Bolaji Olajide
a33b7718aa
feat(batches): sign commits created using a GitHub app credential (#63707)
Closes SRCH-685

When a GitHub app credential is used to push a commit, the commits
aren't signed.
With this PR, we re-use the `DuplicateCommit` method to create a signed
commit so users who don't have a standalone Commit Signing app installed
still get a signed commit when the commit is created with a GitHub app.


![image](https://github.com/sourcegraph/sourcegraph/assets/25608335/3058d05c-c20d-495d-abdf-49d525ec1f43)

To avoid cyclic imports, I had to move the `AuthenticationStrategy`
const to the `internal/types` package and rename it to
`SourceAuthenticationStrategy` so it's clear.

## Test plan

Add a GitHub app as a credential, then create a changeset targeting the
repo that the GitHub app is installed on.
The final commit should be signed.

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
2024-07-09 06:17:34 -05:00
Stefan Hengl
1af563b614
batches: use "keyword" as default pattern type (#63613)
This is part of the Keyword GA Project.

Batch Changes uses Sourcegraph queries to define the list of repositories on which the batch change will run.

With this change we default to pattern type "keyword" instead of "standard". 

To make this a backward compatible change, we also introduce a version identifier to batch specs. Authors can specify `version: 2` in the spec, in which case we default to pattern type "keyword". Existing specs (without a specified version) and specs with `version: 1` will keep using pattern type "standard".

Notes:
- Corresponding doc update [PR](https://github.com/sourcegraph/docs/pull/477)
- We don't have a query input field, but instead the query is defined in a batch spec YAML. It didn't feel right to edit the YAML and append "patternType: " on save, which is what we do for Code Monitors and Insights.
- I misuse the pattern type query parameter to effectively override the version. Once we introduce "V4" we should come back here and clean up. I left a TODO in the code.

Test plan:
- New and updated unit tests
- manual testing
  - new batch changes use `version: 2` by default.
  - using an unsupported version returns an error
  - I ran various "on:" queries to verify that version 2 uses keyword search and version 1 uses standard search.
2024-07-09 10:35:01 +02:00
Bolaji Olajide
a345f75109
fix(batches): fix broken ghauth import (#63693)
An earlier merge of my PR caused `main` to be broken due to an import
change .

## Test plan

<!-- REQUIRED; info at
https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles
-->
Manually built main to ensure there are no other broken imports and
bazel is passing.

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
2024-07-08 20:27:43 +00:00
Bolaji Olajide
acb0818253
feat(batches): allow use of github app token for gitserver push (#63676)
This PR allows the use of GitHub app installation token for Gitserver
push to a codehost.

## Test plan

<!-- REQUIRED; info at
https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles
-->
* Manual testing
* Unit tests should be passing

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
2024-07-08 15:06:11 -05:00
Bolaji Olajide
c0cc1c80af
fix(batches): fix broken credential validator (#63687)
![image](https://github.com/sourcegraph/sourcegraph/assets/25608335/0ca460d3-1464-4248-aa6f-3020cb825cbb)

We had some hardcoded variables to the `ForExternalService` changeset
Sourcer, this PR resolves that.

## Test plan

* manual testing

![CleanShot 2024-07-08 at 14 46
30@2x](https://github.com/sourcegraph/sourcegraph/assets/25608335/744c39e1-22b7-4e6e-bfc1-b0c4e48143b2)

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
2024-07-08 14:13:05 +00:00
Bolaji Olajide
a8ffb7a167
chore(batches): simplify Sourcer interface (#63673) 2024-07-08 08:18:11 +01:00
Michael Bahr
73881aef18
feat: implement functionality to create credential GitHub apps (#63635)
Closes SRCH-663

This is a follow-up to previous PRs, where we added database fields to
support the new github apps integration.

See initiative "Batch Changes using GitHub App auth" on linear.

## Test plan

- Manual testing

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->

---------

Co-authored-by: Bolaji Olajide <25608335+BolajiOlajide@users.noreply.github.com>
2024-07-05 08:56:41 -05:00
Bolaji Olajide
11ec30b85a
feat(batches): implement {site,user} credential authenticator for github apps (#63616)
This implements the previously unimplemented authenticator for
credentials associated with a github app.
Closes SRCH-662

## Test plan

<!-- REQUIRED; info at
https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles
-->
* unit tests
* More tests will be conducted in a follow up PR where this
authenticator will be used to create a changeset.

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
2024-07-04 04:14:23 -05:00
Michael Bahr
fcff7a218b
feat: introduce database fields for github apps <-> batch changes integration, and update database layer (#63577) 2024-07-02 06:12:56 -05:00
Bolaji Olajide
8e2c34c9b1
fix(batch-changes): remove leading and trailing spaces from batch changes credentials (#63517) 2024-06-27 10:32:08 -05:00
Erik Seliger
83d0f6876c
dotcom: Remove on-demand cloning of repositories (#63321)
Historically, sourcegraph.com has been the only instance. It was
connected to GitHub.com and GitLab.com only.
Configuration should be as simple as possible, and we wanted everyone to
try it on any repo. So public repos were added on-demand when browsed
from these code hosts.

Since, dotcom is no longer the only instance, and this is a special case
that only exists for sourcegraph.com.
This causes a bunch of additional complexity and various extra code
paths that we don't test well enough today.

We want to make dotcom simpler to understand, so we've made the decision
to disable that feature, and instead we will maintain a list of
repositories that we have on the instance.
We already disallowed several repos half a year ago, by restricting size
of repos with few stars heavily.
This is basically just a continuation of that.

In the diff, you'll mostly find deletions. This PR does not do much
other than removing the code paths that were only enabled in dotcom mode
in the repo syncer, and then removes code that became unused as a result
of that.

## Test plan

Ran a dotcom mode instance locally, it did not behave differently than a
regular instance wrt. repo cloning.
We will need to verify during the rollout that we're not suddenly
hitting code paths that don't scale to the dotcom size.

## Changelog

Dotcom no longer clones repos on demand.
2024-06-26 14:53:14 -07:00
Erik Seliger
eb70099234
gitserver: Cleanup CreateCommitFromPatch (#62781)
This method is still quite messy, but here's some incremental
improvement:

- The unused unique_ref parameter has been removed to simplify
- The git_apply_args parameter has been replaced with
patch_filenames_no_prefix, to not allow arbitrary arguments to be passed
from clients for improved security
- The repo existence check now lives in the gRPC layer like for all
other resolvers
- Added a docstring to describe how it works

Test plan:

Integration tests are still passing, created a batch change locally to
verify it can still correctly create a PR.
2024-06-07 10:46:05 +02:00
Varun Gandhi
2955bb6cfb
chore: Change errors.HasType to respect multi-errors (#63024)
With this patch, the `errors.HasType` API behaves similar to `Is` and `As`,
where it checks the full error tree instead of just checking a linearized version
of it, as cockroachdb/errors's `HasType` implementation does not respect
multi-errors.

As a consequence, a bunch of relationships between HasType and Is/As that
you'd intuitively expect to hold are now true; see changes to `invariants_test.go`.
2024-06-06 13:02:14 +00:00
Joe Chen
2589fef13e
lib/background: upgrade Routine interface with context and errors (#62136)
This PR is a result/followup of the improvements we've made in the [SAMS repo](https://github.com/sourcegraph/sourcegraph-accounts/pull/199) that allows call sites to pass down a context (primarily to indicate deadline, and of course, cancellation if desired) and collects the error returned from `background.Routine`s `Stop` method.

Note that I did not adopt returning error from `Stop` method because I realize in monorepo, the more common (and arguably the desired) pattern is to hang on the call of `Start` method until `Stop` is called, so it is meaningless to collect errors from `Start` methods as return values anyway, and doing that would also complicate the design and semantics more than necessary.

All usages of the the `background.Routine` and `background.CombinedRoutines` are updated, I DID NOT try to interpret the code logic and make anything better other than fixing compile and test errors.

The only file that contains the core change is the [`lib/background/background.go`](https://github.com/sourcegraph/sourcegraph/pull/62136/files#diff-65c3228388620e91f8c22d91c18faac3f985fc67d64b08612df18fa7c04fafcd).
2024-05-24 10:04:55 -04:00
Erik Seliger
d4489a84e6
syncer: Fix issues causing excessive fetches (#62837)
This PR is the result of quite a journey. You'll see a bunch of meaningless one-liners, and yes - this was a bit frustrating :D

tl;dr I noticed that S2 was fetching repos a ton of times, but the numbers didn't check out. Why would we need 9 fetches a second to keep 1100 repos fresh, of which most are very inactive?
Turns out, we trigger fetches for repos that are marked as modified during code host syncing.
That in itself seems mostly unnecessary (so I reduced the conditions under which that would trigger an immediate update),
and the condition for detecting when a repo was modified was also not correctly computed in a bunch of cases.
These are fixed by one-liners here as well. Most likely, this is not a complete list, but it's what I found locally.

Here's some more writeup:
https://www.notion.so/sourcegraph/May-22-2024-S2-fetches-repos-a-lot-e19c282bb3564140b09086ebce172450?pvs=4

Test plan:

See the notion journey as well, but I verified that the repos are no longer marked as modified erroneously in my local instance.
2024-05-23 20:52:21 +02:00
Erik Seliger
c338a954b9
rockskip: Replace second long-running process with gRPC API (#62734)
We want to migrate the LogReverseEach call to gRPC methods as well.
However, it isn't a great practice to have to keep this process running for potentially hours, as any server restart will have to make the entire process start over.

With one call per commit, we're not occupying a process slot on gitserver, and rollouts of gitserver should much less affect rockskip, as individual commits can be retried before being returned to the rockskip code.

Closes #62100

Test plan:

Existing tests still pass, I let it index a repo locally and that was fast and I get results for symbols instantly now, but not a Rockskip expert so requesting review from the owners.
2024-05-21 17:45:27 +02:00
Noah S-C
9b6ba7741e
bazel: transcribe test ownership to bazel tags (#62664) 2024-05-16 15:51:16 +01:00
Erik Seliger
f852dd21da
gitserver: Make ReadDir return an iterator on client side (#62602)
There is potentially a lot of FDs in a repo, so we return an iterator instead to encourage callers to consume it one by one and not load all of it into memory.

Test plan:

Existing tests still pass.
2024-05-13 14:24:14 +02:00
Erik Seliger
1e51ba8dde
gitserver: Move implementation of HasCommitAfter to caller (#62520)
This is only used in one place, so we're moving the implementation to the caller. Gitserver client only exposes gRPC methods without additional logic on top.

Test plan:

Kept the existing tests but rewrote them to test Commits instead so we don't lose coverage for this.
2024-05-11 01:36:30 +02:00
Erik Seliger
a86237042f
gitserver: Implement CommitLog using Commits (#62518)
This PR reimplements what CommitLog does using Commits. This reduces the surface area, but also removes an API that currently wasn't respecting sub repo permissions properly.
Another side-effect of this is that we have to make more gRPC requests for indexing, but in return we accumulate less data in memory as we don't need to store all paths in all diffs here.

Test plan:

Existing tests still pass, adjusted test suite as well.
2024-05-11 01:21:19 +02:00
Erik Seliger
7a0e6a7b60
gitserver: Move CommitsUniqueToBranch to callsite (#62514)
This has only one caller and is now implemented using existing gitserver stuff, so I'm moving this custom response mapping to where it's used. One less API we need to expose via gRPC.

Test plan:

Adjusted tests, and existing E2E tests still pass.
2024-05-11 01:16:00 +02:00
Erik Seliger
824337ae6d
gitserver: Implement Stat and ReadDir in gRPC API (#62107) 2024-05-11 00:58:28 +02:00
Camden Cheek
750012b168
Batch changes: make window ranges exclusive to avoid infinite loop (#62597)
This fixes an issue where we can potentially make no progress in the main loop of Estimate
2024-05-10 17:41:06 -04:00
Geoffrey Gilmore
b9cb4c580f
gitserver: grpc: remove now unused DiffSymbols func (#62360) 2024-05-07 11:50:00 -07:00
Geoffrey Gilmore
3a3ce68138
gitserver: grpc: add new ChangedFiles method to gitserver client (#62354)
Part of https://github.com/sourcegraph/sourcegraph/issues/60654

This PR builds on https://github.com/sourcegraph/sourcegraph/pull/62216, and creates a new ChangedFiles method in the gitserver client that calls the new gRPC method that was introduced in https://github.com/sourcegraph/sourcegraph/pull/62216.

Note: This PR doesn't change / remove any existing callers of DiffSymbols. I made those changes in future stacked PRs to ensure that they're easy to review. 

## Test plan

New Unit tests
2024-05-07 10:58:06 -07:00
Erik Seliger
75afb74586
gitserver: Utilize Commits method for RevList (#62369)
This PR replaces the gitserver client method RevList by the Commits method.
The Commits method can do the same, but it saves us from implementing and testing a second API. Also, the name RevList sounded very generic but it was super opinionated in the flags it uses, so it was really "ListCommitsForRockskip" but that is too application-specific so Commits is probably just as good.
We'll learn a bunch about our API endpoints as we finish migrating them all, so we can do proper optimizations afterwards.

Closes https://github.com/sourcegraph/sourcegraph/issues/62098

Test plan:

Integration and unit test for rockskip are still passing.
2024-05-06 16:54:59 +02:00
Erik Seliger
186f4a212c
gitserver: Implement CommitGraph using Commits (#62368)
This PR consolidates the client methods CommitGraph and Commits into one, to reduce the surface of APIs we have to migrate to gRPC and then maintain.
To my best understanding, this should be equivalent, just use a different API.

Test plan:

Existing test suites and integration tests are still passing.
2024-05-06 15:58:15 +02:00
Geoffrey Gilmore
a07a3aecf1
gitserver: grpc: create server implementation for GetBehindAhead (#62216)
Part of https://github.com/sourcegraph/sourcegraph/issues/62101

This PR implements the server-side gRPC implementation of GetBehindAhead, and hooks it up to the new git Backend implementation from #62212.

## Test plan

Unit tests
2024-05-03 10:04:53 -07:00
Erik Seliger
1423c2e8c8
rockskip: Switch from long-running process to pagination (#62259)
We want to migrate this call to gRPC. However, it isn't good practice to have to keep this process running for potentially hours, as any server restart will have to make the process start over.
With pagination here, we're not occupying a process slot on gitserver, and rollouts of gitserver should much less affect rockskip, as individual pages can be retried before being returned to the rockskip code.

Test plan:

Existing tests still pass, but not a Rockskip expert so requesting review from the owners.
2024-05-02 02:17:48 +02:00
Bolaji Olajide
02ba39ff28
batches: fix changeset status computation for changesets with skipped ci checks (#62204) 2024-04-30 05:27:02 -05:00
Erik Seliger
b64422df6d
gitserver: Extract repository service in gRPC (#61807)
This PR moves the Fetch and Delete operations onto a separate service.

With that, we also disallow consumers of the internal/gitserver.Client
interface to use these methods. Repo-updaters scheduler has authority
over this and it should not be interfered with. If a caller wants to make
a scheduling _suggestion_, it will be able to talk to repo-updater.

This prepares for a better scheduler that has full control of the operations
running.

Test plan:

E2E and integration tests will verify that repos are still cloned properly.
2024-04-18 20:10:19 +02:00
Erik Seliger
7496005e18
gitserver: Migrate Diff to gRPC call (#61938)
This PR migrates the Diff method to use a proper gRPC method. I decided to call it RawDiff as it streams back the raw diff format.

Later, we can decide to also add a structured endpoint, but for now we'll let the caller decide what to do with the diff string.
There's probably a use-case for both versions.

Closes https://github.com/sourcegraph/sourcegraph/issues/61868

Test plan:

Added tests across all the layers, verified locally that the diff view works.
2024-04-18 15:14:14 +02:00
Erik Seliger
0fdb44568f
gitserver: Serve Refs via gRPC method (#60323)
This PR migrates the ref specific calls to a gRPC endpoint.

While looking at this, I realized that we have many methods that want the same thing in the end: refs.

So instead of adding various endpoints (that currently use porcelain commands in the client implementation), we now use the plumbing command `for-each-ref` for all of them.

By that, we can combine the following APIs:

- `ListRefs` -> `ListRefs` (stays the same)
- `ListBranches` -> `ListBranches(headsOnly: true)`
- `ListTags` -> `ListBranches(tagsOnly: true)`
- For endpoints that were interested in both branches and tags, we allow the combination of the two `only` flags
- `BranchesContaining` -> `ListRefs(contains: sha)`
- `RefDescriptions` -> `ListRefs(headsOnly: true, tagsOnly: true)`

Through one simple call to `for-each-ref`, we also get to enjoy consistent ordering throughout. This also fixes an issue and improves perf for the branch picker where ordering would be random once the count hits 1000. 

Closes https://github.com/sourcegraph/sourcegraph/issues/55074

Closes https://github.com/sourcegraph/sourcegraph/issues/60415

## Test plan

Added tests at various layers, for gitcli, for the gRPC server, for the new client.
Also, existing tests still pass after this migration, including integration and E2E tests.
Manually ran my instance and clicked around as well, to verify.
2024-04-16 14:28:25 +02:00
Erik Seliger
e7d212b0ce
Consolidate DiffPath and Diff methods (#61600)
Diff already has an option for scoping to a specific path, so merging these two together, to simplify the API surface we need to create for the new gRPC APIs around diffs.

## Test plan

Adjusted a few tests, hoping that integration and E2E tests cover this. Also ran some git commands locally to check if they produce roughly equivalent output.
Code reviews will help as well.
2024-04-16 13:23:07 +02:00
Erik Seliger
da5ec1da4c
Break dependency of internal/batches/webhooks on cmd/frontend (#61892)
Was just used for one marshal operation in testing, so this simplifies the dependency graph by not importing from cmd/frontend.

Test plan:

Tests still pass, code compiles.
2024-04-15 21:17:42 +02:00
Camden Cheek
d2eea901b4
Search: add rev:at.time() for searching a repo at a point in time (#61513)
This adds a rev:at.time(5 days ago, my-branch) predicate that allows a user to search a branch at a specific point in time.
2024-04-12 15:14:16 -06:00
Erik Seliger
45e4a19d67
Fix nil dereference from wrong bool operator (#61841)
This seems to have meant to use && instead of || - in the current form this can panic if src is nil.

Test plan:

Code review, trivial change.
2024-04-12 14:06:34 +00:00
Erik Seliger
992317adfc
gitserver: Remove double negation for ensure revision (#61676)
I _ALWAYS_ stumble over this double negation. "If not noensurerevision". huh?

Also, we should not encourage people to accidentally make the server do a resolve revision call which is generally costly, so the cheap option as the default seems more desirable.

For now, I haven't changed any of the values, but we should also do another review of the cases where we explicitly set it to true.

Test plan:

Just converted a bool, CI and E2E tests should catch any issues.
2024-04-11 23:05:49 +02:00
Erik Seliger
90c7f665cd
gitserver: Remove RepoClone gRPC API (#61671)
This was only used for a single purpose that can be achieved in a different way, but would provide a path around our scheduler which makes scheduling decisions harder to understand.
These clones would also not have stuck to the global concurrency limit.

Test plan:

Adjusted tests, tried a reclone locally and it worked.
2024-04-11 16:45:57 +02:00
Keegan Carruthers-Smith
e9d0d57d81
all: use observation.TestContextTB instead of TestContext (#61751)
observation.TestContextTB is better to use since your logs will be
scoped to your test and it will use a more pedantic prometheus registry.
To be honest TestContext should be removed but this is the first step.

This is a mechanical change. I replaced "&observation.TestContext" with
"observation.TestContextTB(t)". I then undid the change each time it
caused a compilation error (was only a handful of times).

Test Plan: go test
2024-04-10 14:07:39 +02:00
Erik Seliger
5a370f22ba
gerrit: Add support for SSH cloning (#61537)
To bring Gerrit support more in line with other code hosts and because a customer recently ran into this limitation, this PR adds support for the SSH flag.

The diff is mostly straightforward, with two things to watch out for:
- The clone URL construction in makeRepo was wrong previously, it missed the `/a/`. This is only used for visuals, but still annoying. So I moved the whole construction into here from the gitserver cloneURL package.
- The SSH hostname and port are configurable in Gerrit, so to construct the right URL we need to fetch some instance metadata. This would be costly to do in the gitserver method, so we persist all the info needed to construct clone URLs "offline" during the cloning process by storing all the data for HTTP and SSH clones on the repo metadata column. This is mostly in line with other code hosts as well, see GitLab right above in the gitserver/cloneurl package.

Closes https://github.com/sourcegraph/sourcegraph/issues/60597

## Test plan

Added tests for the various stages, recreated recorded responses, and tried both HTTP and SSH cloning locally, both worked with out Gerrit instance.
2024-04-04 15:56:51 +02:00
Erik Seliger
daaf9f70c3
gitserver: Remove effectively disabled debouncing of updates (#60584)
The only value we ever passed here was 1 second, which is effectively "don't debounce".
So we can simplify here.

Really, the client should make sure to go at a reasonable pace, and gitserver on the
other end of the wire can have ultimate authority over if it's time for an update or
not.

All existing tests still pass, integration and E2E tests are passing.
2024-03-14 02:04:14 +01:00
Julie Tibshirani
91c154c705
Simplify goroutine params (#61009)
Now that we've updated to Go 1.22, we don't need to copy loop variables before
using them in goroutines.

I found these using the regex searches `go func\(\w+` and `\.Go(func\(\w+`. I
also simplified some non-loop vars when it made sense. 

## Test plan

Straight refactor, covered by existing tests
2024-03-12 09:05:55 -07:00