Skip to content

Commit 8024663

Browse files
authored
Merge branch 'main' into analytics-docs-refresh
2 parents 45350e8 + 5132ec9 commit 8024663

File tree

10 files changed

+166
-105
lines changed

10 files changed

+166
-105
lines changed

docs/admin/auth/index.mdx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -533,9 +533,3 @@ Usernames from authentication providers are normalized before being used in Sour
533533
For example, a user whose external username (according the authentication provider) is `[email protected]` would have the Sourcegraph username `alice-smith`.
534534

535535
If multiple accounts normalize into the same username, separate accounts are still created, but Sourcegraph will add a randomized suffix to the username to ensure uniqueness.
536-
537-
## Remind users to connect external accounts
538-
539-
When authorization is activated, users must link their external code host accounts with their Sourcegraph accounts to access private repositories.
540-
To ensure users are aware of any unlinked accounts, enable the external-accounts-modal feature flag.
541-
This prompts users to connect any missing external accounts upon visiting Sourcegraph.

docs/admin/deploy/docker-compose/aws.mdx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
# Install Sourcegraph on Amazon Web Services (AWS)
22

3-
> ⚠️ We recommend new users use our [AWS AMI](/admin/deploy/machine-images/aws-oneclick) or [script-install](/admin/deploy/single-node/script) instructions, which are easier and offer more flexibility when configuring Sourcegraph. Existing customers can reach out to our Customer Engineering team [email protected] if they wish to migrate to these deployment models.
4-
5-
6-
73
This guide will take you through how to deploy Sourcegraph with [Docker Compose](https://docs.docker.com/compose/) to a single EC2 instance on Amazon Web Services (AWS).
84

9-
Deploy a Sourcegraph instance with an [AWS AMI](/admin/deploy/machine-images/aws-ami) or [AWS One-Click](/admin/deploy/machine-images/aws-oneclick). (Recommended)
10-
115

126
## Configure
137

docs/admin/deploy/docker-compose/azure.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Install Sourcegraph on Azure
22

3-
> ⚠️ We recommend new users use our [machine image](/admin/deploy/machine-images/) or [script-install](/admin/deploy/single-node/script) instructions, which are easier and offer more flexibility when configuring Sourcegraph. Existing customers can reach out to our Customer Engineering team [email protected] if they wish to migrate to these deployment models.
4-
53
This guide will take you through how to set up a Sourcegraph instance on an Azure virtual machine with [Docker Compose](https://docs.docker.com/compose/).
64

75

docs/admin/deploy/docker-compose/digitalocean.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Install Sourcegraph on DigitalOcean
22

3-
> ⚠️ We recommend new users use our [machine image](/admin/deploy/machine-images/) or [script-install](/admin/deploy/single-node/script) instructions, which are easier and offer more flexibility when configuring Sourcegraph. Existing customers can reach out to our Customer Engineering team [email protected] if they wish to migrate to these deployment models.
4-
53
---
64

75
This guide will take you through how to deploy a Sourcegraph instance to a single DigitalOcean Droplet with [Docker Compose](https://docs.docker.com/compose/).

docs/admin/deploy/docker-compose/google_cloud.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Install Sourcegraph on Google Cloud
22

3-
> ⚠️ We recommend new users use our [GCE machine image](/admin/deploy/machine-images/gce) or [script-install](/admin/deploy/single-node/script) instructions, which are easier and offer more flexibility when configuring Sourcegraph. Existing customers can reach out to our Customer Engineering team [email protected] if they wish to migrate to these deployment models.
4-
53
This guide will take you through how to deploy Sourcegraph with [Docker Compose](https://docs.docker.com/compose/) to a single node running on Google Cloud.
64

75
## Configure

docs/admin/deploy/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Single-node, self hosted solution for enterprises looking for a simpler, non-Kub
4949

5050
Best for enterprises looking for a self-hosted solution on the Cloud provider of their choice.
5151

52-
Customized machine images allow you to spin up a preconfigured Sourcegraph instance with just a few clicks, all in less than 10 minutes. Currently available in the following hosts:
52+
Machine images provide a preconfigured Sourcegraph instance that can be deployed in minutes with minimal effort. While they offer simplicity, they are designed as a standardized solution and do not support customization. Currently available on the following hosts:
5353

5454
<QuickLinks>
5555
<QuickLink title="Amazon Machine Image (AMI)" icon='lightbulb' href="/admin/deploy/machine-images/aws-ami" />

docs/admin/deploy/machine-images/aws-oneclick.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This page describes how to launch a verified and pre-configured Sourcegraph instance in just ~10 minutes using our one-click CloudFormation template and standard AMIs.
44

5-
Prefer manually installing on AWS yourself? See our [AMI](/admin/deploy/machine-images/aws-ami) installation options or our [script-install](/admin/deploy/single-node/script) installation options.
5+
Prefer manually installing on AWS yourself? See our [AMI](/admin/deploy/machine-images/aws-ami) installation options.
66

77
## Prerequisites
88

docs/admin/postgres.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ When running an [external PostgreSQL instance](/admin/external_services/postgres
5656
- [Heroku](https://devcenter.heroku.com/articles/upgrading-heroku-postgres-databases)
5757
- [EnterpriseDB](https://www.enterprisedb.com/docs/en/9.6/pg/upgrading.html)
5858
- [Citus](http://docs.citusdata.com/en/v8.1/admin_guide/upgrading_citus.html)
59-
- [Aiven PostgreSQL](https://help.aiven.io/postgresql/operations/how-to-perform-a-postgresql-in-place-major-version-upgrade)
59+
- [Aiven PostgreSQL](https://aiven.io/docs/platform/concepts/maintenance-window#related-pages)
6060
- [Your own PostgreSQL](https://www.postgresql.org/docs/16/pgupgrade.html)
6161
4. Turn Sourcegraph back on connecting to the now-upgraded database.
6262

docs/technical-changelog.mdx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ This page documents all notable changes to Sourcegraph. For more detailed change
66

77
# 5.11 Patch 5
88

9+
> Attention - If upgrading from Sourcegraph version 5.9 or earlier, this release will update our included database container images from Postgres 12 to Postgres 16.
10+
> Customers are advised to have a database backup before upgrading. See our [postgres 12 end of life](https://sourcegraph.com/docs/admin/postgres12_end_of_life_notice#postgres-12-end-of-life) notice for more information.
11+
>
12+
> Also be sure to check your deployment type's [upgrade notes](http://sourcegraph.com/docs/admin/updates#instance-specific-procedures)!
13+
914
## v5.11.6271
1015

1116
- [sourcegraph](https://github.com/sourcegraph/sourcegraph/releases/tag/v5.11.6271)
@@ -35,6 +40,11 @@ This page documents all notable changes to Sourcegraph. For more detailed change
3540

3641
# 5.11 Patch 4
3742

43+
> Attention - If upgrading from Sourcegraph version 5.9 or earlier, this release will update our included database container images from Postgres 12 to Postgres 16.
44+
> Customers are advised to have a database backup before upgrading. See our [postgres 12 end of life](https://sourcegraph.com/docs/admin/postgres12_end_of_life_notice#postgres-12-end-of-life) notice for more information.
45+
>
46+
> Also be sure to check your deployment type's [upgrade notes](http://sourcegraph.com/docs/admin/updates#instance-specific-procedures)!
47+
3848
## v5.11.5234
3949

4050
- [sourcegraph](https://github.com/sourcegraph/sourcegraph/releases/tag/v5.11.5234)
@@ -73,6 +83,11 @@ This page documents all notable changes to Sourcegraph. For more detailed change
7383

7484
# 5.11 Patch 3
7585

86+
> Attention - If upgrading from Sourcegraph version 5.9 or earlier, this release will update our included database container images from Postgres 12 to Postgres 16.
87+
> Customers are advised to have a database backup before upgrading. See our [postgres 12 end of life](https://sourcegraph.com/docs/admin/postgres12_end_of_life_notice#postgres-12-end-of-life) notice for more information.
88+
>
89+
> Also be sure to check your deployment type's [upgrade notes](http://sourcegraph.com/docs/admin/updates#instance-specific-procedures)!
90+
7691
## v5.11.4013
7792

7893
- [sourcegraph](https://github.com/sourcegraph/sourcegraph/releases/tag/v5.11.4013)
@@ -120,6 +135,11 @@ This page documents all notable changes to Sourcegraph. For more detailed change
120135

121136
# 5.11 Patch 2
122137

138+
> Attention - If upgrading from Sourcegraph version 5.9 or earlier, this release will update our included database container images from Postgres 12 to Postgres 16.
139+
> Customers are advised to have a database backup before upgrading. See our [postgres 12 end of life](https://sourcegraph.com/docs/admin/postgres12_end_of_life_notice#postgres-12-end-of-life) notice for more information.
140+
>
141+
> Also be sure to check your deployment type's [upgrade notes](http://sourcegraph.com/docs/admin/updates#instance-specific-procedures)!
142+
123143
## v5.11.3601
124144

125145
- [sourcegraph](https://github.com/sourcegraph/sourcegraph/releases/tag/v5.11.3601)
@@ -145,6 +165,11 @@ This page documents all notable changes to Sourcegraph. For more detailed change
145165

146166
# 5.11 Patch 1
147167

168+
> Attention - If upgrading from Sourcegraph version 5.9 or earlier, this release will update our included database container images from Postgres 12 to Postgres 16.
169+
> Customers are advised to have a database backup before upgrading. See our [postgres 12 end of life](https://sourcegraph.com/docs/admin/postgres12_end_of_life_notice#postgres-12-end-of-life) notice for more information.
170+
>
171+
> Also be sure to check your deployment type's [upgrade notes](http://sourcegraph.com/docs/admin/updates#instance-specific-procedures)!
172+
148173
## v5.11.2732
149174

150175
- [sourcegraph](https://github.com/sourcegraph/sourcegraph/releases/tag/v5.11.2732)
@@ -178,7 +203,8 @@ This page documents all notable changes to Sourcegraph. For more detailed change
178203

179204
# 5.11 Patch 0
180205

181-
> Warning: This release updates the database container images from Postgres 12 to Postgres 16, and begins using Wolfi based images. Customers are advised to have a database backup before upgrading! See our [postgres 12 end of life](https://sourcegraph.com/docs/admin/postgres12_end_of_life_notice#postgres-12-end-of-life) notice!
206+
> Attention - If upgrading from Sourcegraph version 5.9 or earlier, this release will update our included database container images from Postgres 12 to Postgres 16.
207+
> Customers are advised to have a database backup before upgrading. See our [postgres 12 end of life](https://sourcegraph.com/docs/admin/postgres12_end_of_life_notice#postgres-12-end-of-life) notice for more information.
182208
>
183209
> Also be sure to check your deployment type's [upgrade notes](http://sourcegraph.com/docs/admin/updates#instance-specific-procedures)!
184210

src/middleware.ts

Lines changed: 136 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,141 @@
1-
import { NextResponse } from 'next/server'
2-
import type { NextRequest } from 'next/server'
3-
import docsConfig from '../docs.config.js'
4-
5-
const { updatedRedirectsData } = require('./data/redirects.ts');
6-
7-
function createRedirectUrl(request: NextRequest, destination: string, path: string): string {
8-
// Handle absolute URLs
9-
if (destination.startsWith('http')) {
10-
// Handle dynamic slug replacements
11-
if (destination.includes(':slug')) {
12-
const slugMatch = path.match(/[^/]+$/)
13-
const slug = slugMatch ? slugMatch[0] : ''
14-
destination = destination.replace(':slug*', slug)
15-
}
16-
// Handle version replacements
17-
if (destination.includes(':version')) {
18-
const versionMatch = path.match(/\d+\.\d+/)
19-
const version = versionMatch ? versionMatch[0] : ''
20-
destination = destination.replace(':version', version)
21-
}
22-
23-
return destination
24-
}
25-
26-
// Handle relative paths
27-
const basePath = '/docs'
28-
return destination.startsWith('/') ?
29-
`${request.nextUrl.origin}${basePath}${destination}` :
30-
`${request.nextUrl.origin}${basePath}/${destination}`
31-
}
1+
import type { NextRequest } from 'next/server';
2+
import { NextResponse } from 'next/server';
3+
import docsConfig from '../docs.config.js';
4+
5+
const {updatedRedirectsData} = require('./data/redirects.ts');
6+
7+
function createRedirectUrl(
8+
request: NextRequest,
9+
destination: string,
10+
path: string
11+
): string {
12+
// Handle absolute URLs
13+
if (destination.startsWith('http')) {
14+
// Extract version and full path after version
15+
const versionMatch = path.match(/(?:\/v\/|@)(\d+\.\d+)\/(.*)/);
16+
17+
if (versionMatch) {
18+
const version = versionMatch[1];
19+
const remainingPath = versionMatch[2];
20+
21+
// Find matching redirect for the remaining path
22+
const redirect = updatedRedirectsData.find(
23+
(r: any) =>
24+
r.source === `/${remainingPath}` ||
25+
r.source === remainingPath
26+
);
27+
28+
// If redirect exists, use its destination, otherwise use the remaining path
29+
const finalPath = redirect
30+
? redirect.destination.replace(/^\//, '')
31+
: remainingPath;
32+
33+
// Replace placeholders and construct final URL
34+
return destination
35+
.replace(':version', version)
36+
.replace(':slug*', finalPath);
37+
}
38+
39+
// Handle other cases as before
40+
if (destination.includes(':slug')) {
41+
const slugMatch = path.match(/[^/]+$/);
42+
const slug = slugMatch ? slugMatch[0] : '';
43+
destination = destination.replace(':slug*', slug);
44+
}
45+
46+
return destination;
47+
}
3248

49+
// Handle relative paths
50+
const basePath = '/docs';
51+
return destination.startsWith('/')
52+
? `${request.nextUrl.origin}${basePath}${destination}`
53+
: `${request.nextUrl.origin}${basePath}/${destination}`;
54+
}
3355
export function middleware(request: NextRequest) {
34-
const path = request.nextUrl.pathname
35-
const pathWithoutBase = path.replace('/docs', '')
36-
37-
// Handle base redirects from redirects.ts
38-
const redirect = updatedRedirectsData.find((r: any) => r.source === pathWithoutBase)
39-
if (redirect) {
40-
return NextResponse.redirect(createRedirectUrl(request, redirect.destination, path))
41-
}
42-
// Handle version without slug
43-
const versionOnlyMatch = pathWithoutBase.match(/^\/v\/(\d+\.\d+)$/)
44-
if (versionOnlyMatch) {
45-
return NextResponse.redirect(`https://${versionOnlyMatch[1]}.sourcegraph.com/`)
46-
}
47-
// Handle version-specific redirects
48-
if (pathWithoutBase.startsWith(`/v/${docsConfig.DOCS_LATEST_VERSION}/`)) {
49-
return NextResponse.redirect(createRedirectUrl(
50-
request,
51-
`https://sourcegraph.com/docs/:slug*`,
52-
pathWithoutBase
53-
))
54-
}
55-
if (pathWithoutBase.startsWith(`/@${docsConfig.DOCS_LATEST_VERSION}/`)) {
56-
return NextResponse.redirect(createRedirectUrl(
57-
request,
58-
`https://sourcegraph.com/docs/:slug*`,
59-
pathWithoutBase
60-
))
61-
}
62-
const versionMatch = pathWithoutBase.match(/^\/v\/(\d+\.\d+)\/(.*)/)
63-
if (versionMatch) {
64-
return NextResponse.redirect(createRedirectUrl(
65-
request,
66-
'https://:version.sourcegraph.com/:slug*',
67-
pathWithoutBase
68-
))
69-
}
70-
const atVersionMatch = pathWithoutBase.match(/^\/@(\d+\.\d+)\/(.*)/)
71-
if (atVersionMatch) {
72-
return NextResponse.redirect(createRedirectUrl(
73-
request,
74-
'https://:version.sourcegraph.com/:slug*',
75-
pathWithoutBase
76-
))
77-
}
78-
if (pathWithoutBase === '/changelog.rss')
79-
return NextResponse.redirect(createRedirectUrl(request, '/technical-changelog.rss', path))
80-
81-
return NextResponse.next()
56+
const path = request.nextUrl.pathname;
57+
const pathWithoutBase = path.replace('/docs', '');
58+
59+
// Handle base redirects from redirects.ts
60+
const redirect = updatedRedirectsData.find(
61+
(r: any) => r.source === pathWithoutBase
62+
);
63+
if (redirect) {
64+
return NextResponse.redirect(
65+
createRedirectUrl(request, redirect.destination, path)
66+
);
67+
}
68+
69+
// Handle latest version without path - redirect to main docs
70+
const latestVersionOnlyMatch = pathWithoutBase.match(
71+
`^\/(?:v\/|@)${docsConfig.DOCS_LATEST_VERSION}\/?$`
72+
);
73+
if (latestVersionOnlyMatch) {
74+
return NextResponse.redirect(`https://sourcegraph.com/docs`);
75+
}
76+
77+
// Handle version without slug - both /v/X.Y and @X.Y formats (for non-latest versions)
78+
const versionOnlyMatch = pathWithoutBase.match(
79+
/^\/(?:v\/|@)(\d+\.\d+)\/?$/
80+
);
81+
if (
82+
versionOnlyMatch &&
83+
versionOnlyMatch[1] !== docsConfig.DOCS_LATEST_VERSION
84+
) {
85+
return NextResponse.redirect(
86+
`https://${versionOnlyMatch[1]}.sourcegraph.com/`
87+
);
88+
}
89+
90+
// Handle version-specific redirects
91+
if (pathWithoutBase.startsWith(`/v/${docsConfig.DOCS_LATEST_VERSION}/`)) {
92+
return NextResponse.redirect(
93+
createRedirectUrl(
94+
request,
95+
`https://sourcegraph.com/docs/:slug*`,
96+
pathWithoutBase
97+
)
98+
);
99+
}
100+
if (pathWithoutBase.startsWith(`/@${docsConfig.DOCS_LATEST_VERSION}/`)) {
101+
return NextResponse.redirect(
102+
createRedirectUrl(
103+
request,
104+
`https://sourcegraph.com/docs/:slug*`,
105+
pathWithoutBase
106+
)
107+
);
108+
}
109+
const versionMatch = pathWithoutBase.match(/^\/v\/(\d+\.\d+)\/(.*)/);
110+
if (versionMatch) {
111+
return NextResponse.redirect(
112+
createRedirectUrl(
113+
request,
114+
'https://:version.sourcegraph.com/:slug*',
115+
pathWithoutBase
116+
)
117+
);
118+
}
119+
const atVersionMatch = pathWithoutBase.match(/^\/@(\d+\.\d+)\/(.*)/);
120+
121+
if (atVersionMatch) {
122+
return NextResponse.redirect(
123+
createRedirectUrl(
124+
request,
125+
'https://:version.sourcegraph.com/:slug*',
126+
pathWithoutBase
127+
)
128+
);
129+
}
130+
131+
if (pathWithoutBase === '/changelog.rss')
132+
return NextResponse.redirect(
133+
createRedirectUrl(request, '/technical-changelog.rss', path)
134+
);
135+
136+
return NextResponse.next();
82137
}
83138

84139
export const config = {
85-
matcher: [
86-
'/((?!api|_next/static|_next/image|assets|favicon.ico|sw.js).*)',
87-
],
88-
}
140+
matcher: ['/((?!api|_next/static|_next/image|assets|favicon.ico|sw.js).*)']
141+
};

0 commit comments

Comments
 (0)