Skip to content

Commit f20ed81

Browse files
authored
Merge pull request github#20442 from github/repo-sync
repo sync
2 parents b8f73fb + f2a5f9c commit f20ed81

File tree

8 files changed

+28
-15
lines changed

8 files changed

+28
-15
lines changed

.github/actions-scripts/enterprise-server-issue-templates/release-issue.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ If you aren't comfortable going through the steps alone, sync up with a docs eng
1818
```
1919
script/update-enterprise-dates.js
2020
```
21-
- [ ] Create REST files based on previous version. Copy the latest GHES version of the dereferenced file from `lib/rest/static/dereferenced` to a new file in the same directory for the new GHES release. Ex, `cp lib/rest/static/dereferenced/ghes-3.4.deref.json lib/rest/static/dereferenced/ghes-3.5.deref.json`. Then run `script/rest/updated-files.js --decorate-only` and check in the resulting files.
21+
- [ ] Create REST files based on previous version. Copy the latest GHES version of the dereferenced file from `lib/rest/static/dereferenced` to a new file in the same directory for the new GHES release. Ex, `cp lib/rest/static/dereferenced/ghes-3.4.deref.json lib/rest/static/dereferenced/ghes-3.5.deref.json`. Then run `script/rest/update-files.js --decorate-only` and check in the resulting files.
2222
2323
- [ ] Create GraphQL files based on previous version:
2424

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ env:
2323
# Setting this will activate the jest tests that depend on actually
2424
# sending real search queries to Elasticsearch
2525
ELASTICSEARCH_URL: http://localhost:9200/
26+
# Hopefully the name is clear enough. By enabling this, we're testing
27+
# the future code.
28+
ENABLE_SEARCH_RESULTS_PAGE: true
2629

2730
jobs:
2831
test:

content/get-started/importing-your-projects-to-github/importing-source-code-to-github/adding-locally-hosted-code-to-github.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ If you have existing source code or repositories stored locally on your computer
6666
$ git init -b main
6767
```
6868

69-
If you’re using Git 2.27.1 or an earlier version, you can set the name of the default branch using `&& git branch -m`.
69+
If you’re using Git 2.27.1 or an earlier version, you can set the name of the default branch using `&& git symbolic-ref HEAD refs/heads/main`.
7070

7171
``` shell
72-
$ git init && git branch -m main
72+
$ git init && git symbolic-ref HEAD refs/heads/main
7373
```
7474
5. Add the files in your new local repository. This stages them for the first commit.
7575

@@ -113,10 +113,10 @@ If you have existing source code or repositories stored locally on your computer
113113
$ git init -b main
114114
```
115115

116-
If you’re using Git 2.27.1 or an earlier version, you can set the name of the default branch using `&& git branch -m`.
116+
If you’re using Git 2.27.1 or an earlier version, you can set the name of the default branch using `&& git symbolic-ref HEAD refs/heads/main`.
117117

118118
``` shell
119-
$ git init && git branch -m main
119+
$ git init && git symbolic-ref HEAD refs/heads/main
120120
```
121121
5. Add the files in your new local repository. This stages them for the first commit.
122122
```shell
@@ -159,10 +159,10 @@ If you have existing source code or repositories stored locally on your computer
159159
$ git init -b main
160160
```
161161

162-
If you’re using Git 2.27.1 or an earlier version, you can set the name of the default branch using `&& git branch -m`.
162+
If you’re using Git 2.27.1 or an earlier version, you can set the name of the default branch using `&& git symbolic-ref HEAD refs/heads/main`.
163163

164164
``` shell
165-
$ git init && git branch -m main
165+
$ git init && git symbolic-ref HEAD refs/heads/main
166166
```
167167
5. Add the files in your new local repository. This stages them for the first commit.
168168
```shell

middleware/redirects/handle-redirects.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,31 +39,31 @@ export default function handleRedirects(req, res, next) {
3939
let redirect = req.path
4040
let queryParams = req._parsedUrl.query
4141

42-
// If process.env.ELASTICSEARCH_URL isn't set, you can't go to the
42+
// If process.env.ENABLE_SEARCH_RESULTS_PAGE isn't set, you can't go to the
4343
// dedicated search results page.
4444
// If that's the case, use the "old redirect" where all it does is
4545
// "correcting" the old query string 'q' to 'query'.
46-
if (!process.env.ELASTICSEARCH_URL && 'q' in req.query && !('query' in req.query)) {
46+
if (!process.env.ENABLE_SEARCH_RESULTS_PAGE && 'q' in req.query && !('query' in req.query)) {
4747
// update old-style query params (#9467)
4848
const newQueryParams = new URLSearchParams(queryParams)
4949
newQueryParams.set('query', newQueryParams.get('q'))
5050
newQueryParams.delete('q')
5151
return res.redirect(301, `${req.path}?${newQueryParams.toString()}`)
5252
}
5353

54-
// If process.env.ELASTICSEARCH_URL is set, the dedicated search
54+
// If process.env.ENABLE_SEARCH_RESULTS_PAGE is set, the dedicated search
5555
// result page is ready. If that's the case, we can redirect to
5656
// `/$locale/search?query=...` from `/foo/bar?query=...` or from
5757
// (the old style) `/foo/bar/?q=...`
5858
if (
59-
process.env.ELASTICSEARCH_URL &&
59+
process.env.ENABLE_SEARCH_RESULTS_PAGE &&
6060
('q' in req.query ||
6161
('query' in req.query &&
6262
!(req.path.endsWith('/search') || req.path.startsWith('/api/search'))))
6363
) {
6464
// If you had the old legacy format of /some/uri?q=stuff
6565
// it needs to redirect to /en/search?query=stuff or
66-
// /some/uri?query=stuff depending on if ELASTICSEARCH_URL has been
66+
// /some/uri?query=stuff depending on if ENABLE_SEARCH_RESULTS_PAGE has been
6767
// set up.
6868
// If you have the new format of /some/uri?query=stuff it too needs
6969
// to redirect to /en/search?query=stuff

pages/search.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ export const getServerSideProps: GetServerSideProps<Props> = async (context) =>
2626
// So if that's the case, which might be true in production (Aug 2022)
2727
// or on an engineers local development, we basically pretend the
2828
// page doesn't exist.
29-
if (!process.env.ELASTICSEARCH_URL) {
29+
// By depending conditionally on these two environment variables we're
30+
// able to carefully launch the dedicated search results page
31+
// separately from the JSON API endpoint.
32+
if (!process.env.ELASTICSEARCH_URL || !process.env.ENABLE_SEARCH_RESULTS_PAGE) {
3033
return { notFound: true }
3134
}
3235

tests/helpers/conditional-runs.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ const runningActionsOnInternalRepo =
44
export const testViaActionsOnly = runningActionsOnInternalRepo ? test : test.skip
55
export const describeViaActionsOnly = runningActionsOnInternalRepo ? describe : describe.skip
66
export const describeIfElasticsearchURL = process.env.ELASTICSEARCH_URL ? describe : describe.skip
7+
export const describeIfDedicatedSearchResultsPage = process.env.ENABLE_SEARCH_RESULTS_PAGE
8+
? describe
9+
: describe.skip
710

811
export default {
912
testViaActionsOnly,
1013
describeViaActionsOnly,
1114
describeIfElasticsearchURL,
15+
describeIfDedicatedSearchResultsPage,
1216
}

tests/rendering/search.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { expect, jest } from '@jest/globals'
22

33
import { getDOM } from '../helpers/e2etest.js'
4+
import { describeIfDedicatedSearchResultsPage } from '../helpers/conditional-runs.js'
45

5-
describe('search results page', () => {
6+
describeIfDedicatedSearchResultsPage('search results page', () => {
67
jest.setTimeout(5 * 60 * 1000)
78

89
test('says something if no query is provided', async () => {

tests/routing/redirects.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url))
1616
// dedicated search results page works.
1717
// In a near future, we won't be needing this and assume it's always
1818
// true.
19-
const USE_DEDICATED_SEARCH_RESULTS_PAGE = Boolean(process.env.ELASTICSEARCH_URL)
19+
const USE_DEDICATED_SEARCH_RESULTS_PAGE = Boolean(
20+
JSON.parse(process.env.ENABLE_SEARCH_RESULTS_PAGE || 'false')
21+
)
2022

2123
describe('redirects', () => {
2224
jest.setTimeout(5 * 60 * 1000)

0 commit comments

Comments
 (0)