Skip to content

VSCE: fix default branch behavior

Administrator requested to merge bee/vsce-default-branch into main

Created by: abeatrix

Summary

close https://github.com/sourcegraph/sourcegraph/issues/36743

Current Behavior

If a user has configured to always open files with their default branch, we will always open the default branch without checking if it exists on Sourcegraph. A bug has been located that current branch will still be used even if default branch is set: (link to code)

Solution

Check if the default branch also exists on Sourcegraph, and display a message to let the user know the default branch does not exist on Sourcegraph accordingly (link to code). IF default branch exists, open default branch

Screenshots

Situation: When no default branch is set, and the current branch does not exist on Sourcegraph. Behavior: Display a message to let users know the branch does not exist on Sourcegraph: image

Situation: When the default branch is set to master, and the current branch does not exist on Sourcegraph. Behavior: Open file on default branch: image

Situation: When the default branch is set to master, and the current branch exists on Sourcegraph. Behavior: Open file on default branch: image

Test plan

The integration test is passing:

❯ yarn test-integration
yarn run v1.22.17
warning @sourcegraph/[email protected]: The engine "vscode" appears to be invalid.
$ TS_NODE_PROJECT=tests/tsconfig.json mocha --parallel=$CI --retries=2 ./tests/**/*.test.ts


  VS Code extension
Downloading VS Code 1.68.0 from https://update.code.visualstudio.com/1.68.0/darwin-arm64/stable
Downloading VS Code [==============================] 100%Downloaded VS Code 1.68.0 into /Users/b/Dev/sourcegraph/client/vscode/.vscode-test/vscode-darwin-1.68.0
Starting VS Code {
  verbose: false,
  vscodeExecutablePath: '/Users/b/Dev/sourcegraph/client/vscode/.vscode-test/vscode-darwin-1.68.0/Vis'... 43 more characters,
  userDataDirectory: '/var/folders/g1/f24vdsfn2mb1z2_wwyl5vygh0000gn/T/vsce0Q7Abo',
  extensionsDirectory: '/var/folders/g1/f24vdsfn2mb1z2_wwyl5vygh0000gn/T/vscedQ7Ufz'
}
VSCode started in debug mode on http://127.0.0.1:29378
    ✓ works (9940ms)


  1 passing (45s)

✨  Done in 54.23s.

To run integration test:

  1. yarn && yarn generate from root of the repo
  2. cd client/vscode
  3. yarn build:test
  4. yarn test-integration

App preview:

Check out the client app preview documentation to learn more.

Merge request reports

Loading