Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/1-invalid-arguments-retrieving-info…
Browse files Browse the repository at this point in the history
…-for-some-prs
  • Loading branch information
ankitbko authored Jan 8, 2024
2 parents 88052a2 + 2f4aacd commit 28b7eaa
Show file tree
Hide file tree
Showing 28 changed files with 1,670 additions and 260 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -353,4 +353,5 @@ preview-src

.eslintcache
.eslintcache.browser
*.tsbuildinfo
*.tsbuildinfo
.vscode-test-web
50 changes: 47 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--disable-extension=GitHub.vscode-pull-request-github-insiders"
"--disable-extension=GitHub.vscode-pull-request-github"
],
"skipFiles": ["<node_internals>/**/*.js", "**/node_modules/**/*.js"],
"smartStep": true,
Expand All @@ -23,6 +23,7 @@
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--disable-extension=GitHub.vscode-pull-request-github",
"--disable-extension=GitHub.vscode-pull-request-github-insiders"
],
"skipFiles": ["<node_internals>/**/*.js", "**/node_modules/**/*.js"],
Expand All @@ -37,7 +38,7 @@
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--disable-extension=GitHub.vscode-pull-request-github-insiders",
"--disable-extension=GitHub.vscode-pull-request-github",
],
"skipFiles": ["<node_internals>/**/*.js", "**/node_modules/**/*.js"],
"preLaunchTask": "npm: watch",
Expand All @@ -53,7 +54,7 @@
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--disable-extension=GitHub.vscode-pull-request-github-insiders",
"--disable-extension=GitHub.vscode-pull-request-github",
],
"skipFiles": ["<node_internals>/**/*.js", "**/node_modules/**/*.js"],
"preLaunchTask": "npm: watch",
Expand All @@ -77,6 +78,49 @@
"smartStep": true,
"sourceMaps": true,
"outFiles": ["${workspaceFolder}/out/src/test/**/*.js"]
},
{
"type": "pwa-node",
"request": "launch",
"name": "Attach Web Test",
"program": "${workspaceFolder}/node_modules/@vscode/test-web/out/index.js",
"args": [
"--extensionTestsPath=dist/browser/test/index.js",
"--extensionDevelopmentPath=.",
"--browserType=chromium",
"--attach=9229"
],
"cascadeTerminateToConfigurations": [
"Launch Web Test"
],
"presentation": {
"hidden": true,
}
},
{
"type": "pwa-chrome",
"request": "launch",
"name": "Launch Web Test",
"skipFiles": [
"<node_internals>/**"
],
"port": 9229,
"resolveSourceMapLocations": [
"!**/vs/**", // exclude core vscode sources
"!**/static/build/extensions/**", // exclude built-in extensions
],
"presentation": {
"hidden": true,
}
}
],
"compounds": [
{
"name": "Debug Web Test",
"configurations": [
"Attach Web Test",
"Launch Web Test"
]
}
]
}
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 0.2.1
- Fixed continuous popup for authentication.

## 0.2.0
- Fixed [#68](https://github.com/ankitbko/vscode-pull-request-azdo/issues/68) - Changed the authentication mechanism from PAT to OAuth using vscode provided authentication session. This will require users to re-authenticate.

## 0.0.25

- Removed explicit check of azdo url to resolve [#55](https://github.com/ankitbko/vscode-pull-request-azdo/issues/55)
Expand Down
18 changes: 7 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,13 @@ It's easy to get started with Azure Devops Pull Requests for Visual Studio Code.
1. Reload VS Code after the installation (click the reload button next to the extension).
1. Open your desired Azure Devops repository.
1. You will need to configure the `azdoPullRequests.projectName` and `azdoPullRequests.orgUrl` setting. You can configure it in workspace settings and commit it so others in your team wouldn't need to do this configuration again. (Look at the next section to understand the format of these settings).
1. You will need to configure [PAT token in Azure Devops](https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=preview-page) to login. Click on _show all scopes_ and select the following scopes for the token - `Code: Read & Write`, `Pull Request Threads: Read & Write`, `Work Items: Read & Write`, `Member Entitlement Management: Read`. Read more about these scope in next section.
1. A new tab would have appeared on the activity bar on the left. Open it and click on `Sign in` button. Enter the PAT token and press enter.
1. Signin to VS Code using same Microsoft account that you use to signin to Azure Devops. Authentication will work automatically. **PAT token is no longer required**.
1. You should be good to go!

## Features

Learn all about different features of the extension in the [wiki](https://github.com/ankitbko/vscode-pull-request-azdo/wiki).

### Scopes required by PAT Token

- **Minimum**: These scopes are required for extension to access Pull Requests and Threads. Without these scopes the extension will not even start.
- `Code: Read & Write`: Required to access repository metadata and pull requests.
- `Pull Request Threads: Read & Write`: Access Pull Request comment threads.
- **Additional**: These scopes are required to experience the extension in its completeness. Without these some functionality of extension may not work or the extension may cause errors.
- `Work Items: Read & Write`: Allow to read and associate work items to a PR.
- `Member Entitlement Management: Read`: Used to search for users when adding reviewers to PR.

## Configuring the extension

#### azdoPullRequests.orgUrl
Expand Down Expand Up @@ -75,6 +65,12 @@ Learn all about different features of the extension in the [wiki](https://github
- _default_: mergebase
- _Description_: The commit to use to get diff against the PR branch's HEAD. Read more about different options in [wiki](https://github.com/ankitbko/vscode-pull-request-azdo/wiki/Diff-Options-HEAD-vs-Merge-Base)

#### azdoPullRequests.patToken
- _type_: string
- _required_: false
- _default_: ""
- _Description_: The PAT Token from Azure DevOps, if provided extension will not prompt for Microsoft login instead it will login using provided PAT

## Known Major Issues

1. Mentions in comments are not resolved to user and no hover support
Expand Down
28 changes: 22 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
},
"enableProposedApi": false,
"preview": true,
"version": "0.0.25",
"version": "0.2.1",
"publisher": "ankitbko",
"engines": {
"vscode": "^1.53.0"
"vscode": "^1.79.0"
},
"categories": [
"Other"
Expand All @@ -29,7 +29,8 @@
"capabilities": {
"untrustedWorkspaces": {
"supported": true
}
},
"virtualWorkspaces": true
},
"contributes": {
"configuration": {
Expand All @@ -42,6 +43,11 @@
"azdoPullRequests.orgUrl": {
"type": "string"
},
"azdoPullRequests.patToken": {
"type": "string",
"default": "",
"description": "Personal Access Token for Azure Devops"
},
"azdoPullRequests.telemetry.enabled": {
"type": "boolean",
"default": true,
Expand Down Expand Up @@ -732,6 +738,8 @@
"scripts": {
"postinstall": "yarn update-dts",
"vscode:prepublish": "yarn run bundle",
"browsertest:preprocess": "yarn run compile && tsc ./src/test/browser/runTests.ts --outDir ./dist/browser/test --rootDir ./src/test/browser --target es6 --module commonjs",
"browsertest": "yarn run browsertest:preprocess && node ./dist/browser/test/runTests.js",
"bundle": "webpack --mode production --env esbuild",
"bundle:node": "webpack --mode production --config-name extension:node --config-name webviews",
"bundle:web": "webpack --mode production --config-name extension:webworker --config-name webviews",
Expand Down Expand Up @@ -763,12 +771,17 @@
"@types/sinon": "7.0.11",
"@types/temp": "0.8.34",
"@types/uuid": "^8.3.0",
"@types/vscode": "1.79.0",
"@types/webpack-env": "^1.16.0",
"@typescript-eslint/eslint-plugin": "4.18.0",
"@typescript-eslint/parser": "4.18.0",
"@vscode/test-electron": "^1.6.1",
"@vscode/test-web": "^0.0.8",
"assert": "2.0.0",
"browserify-zlib": "0.2.0",
"buffer": "6.0.3",
"buffer": "^6.0.3",
"chai": "^4.2.0",
"constants-browserify": "^1.0.0",
"crypto-browserify": "3.12.0",
"css-loader": "5.1.3",
"dotenv": "^8.2.0",
Expand All @@ -779,7 +792,7 @@
"eslint-plugin-import": "2.22.1",
"fork-ts-checker-webpack-plugin": "6.1.1",
"glob": "7.1.6",
"https-browserify": "1.0.0",
"https-browserify": "^1.0.0",
"jsdom": "16.4.0",
"jsdom-global": "3.0.2",
"json5": "2.2.0",
Expand All @@ -791,13 +804,14 @@
"mocha-multi-reporters": "1.1.7",
"path-browserify": "1.0.1",
"prettier": "2.2.1",
"process": "^0.11.10",
"raw-loader": "4.0.2",
"react-testing-library": "7.0.1",
"remark-gfm": "^1.0.0",
"sinon": "9.0.0",
"source-map-support": "0.5.19",
"stream-browserify": "^3.0.0",
"stream-http": "3.1.1",
"stream-http": "^3.2.0",
"style-loader": "2.0.0",
"svg-inline-loader": "^0.8.2",
"temp": "0.9.4",
Expand All @@ -807,6 +821,7 @@
"tty": "1.0.1",
"ttypescript": "^1.5.12",
"typescript": "4.2.3",
"url": "^0.11.0",
"util": "0.12.3",
"vsce": "1.87.0",
"vscode-test": "^1.5.1",
Expand All @@ -831,6 +846,7 @@
"moment": "^2.22.1",
"node-emoji": "^1.8.1",
"node-fetch": "3.0.0-beta.9",
"os-browserify": "^0.3.0",
"query-string": "^6.2.0",
"react": "^16.12.0",
"react-dom": "^16.12.0",
Expand Down
47 changes: 45 additions & 2 deletions src/@types/git.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/


import { Uri, Event, Disposable, ProviderResult } from 'vscode';
export { ProviderResult } from 'vscode';

Expand All @@ -14,6 +15,11 @@ export interface InputBox {
value: string;
}

export const enum ForcePushMode {
Force,
ForceWithLease
}

export const enum RefType {
Head,
RemoteHead,
Expand Down Expand Up @@ -130,6 +136,16 @@ export interface CommitOptions {
signoff?: boolean;
signCommit?: boolean;
empty?: boolean;
noVerify?: boolean;
requireUserConfig?: boolean;
}

export interface FetchOptions {
remote?: string;
ref?: string;
all?: boolean;
prune?: boolean;
depth?: number;
}

export interface BranchQuery {
Expand Down Expand Up @@ -190,9 +206,10 @@ export interface Repository {
removeRemote(name: string): Promise<void>;
renameRemote(name: string, newName: string): Promise<void>;

fetch(options?: FetchOptions): Promise<void>;
fetch(remote?: string, ref?: string, depth?: number): Promise<void>;
pull(unshallow?: boolean): Promise<void>;
push(remoteName?: string, branchName?: string, setUpstream?: boolean): Promise<void>;
push(remoteName?: string, branchName?: string, setUpstream?: boolean, force?: ForcePushMode): Promise<void>;

blame(path: string): Promise<string>;
log(options?: LogOptions): Promise<Commit[]>;
Expand All @@ -211,13 +228,34 @@ export interface RemoteSourceProvider {
readonly icon?: string; // codicon name
readonly supportsQuery?: boolean;
getRemoteSources(query?: string): ProviderResult<RemoteSource[]>;
getBranches?(url: string): ProviderResult<string[]>;
publishRepository?(repository: Repository): Promise<void>;
}

export interface Credentials {
readonly username: string;
readonly password: string;
}

export interface CredentialsProvider {
getCredentials(host: Uri): ProviderResult<Credentials>;
}

export interface PushErrorHandler {
handlePushError(repository: Repository, remote: Remote, refspec: string, error: Error & { gitErrorCode: GitErrorCodes }): Promise<boolean>;
}

export type APIState = 'uninitialized' | 'initialized';

export interface PublishEvent {
repository: Repository;
branch?: string;
}

export interface GitAPI {
readonly state: APIState;
readonly onDidChangeState: Event<APIState>;
readonly onDidPublish: Event<PublishEvent>;
readonly git: Git;
readonly repositories: Repository[];
readonly onDidOpenRepository: Event<Repository>;
Expand All @@ -226,7 +264,11 @@ export interface GitAPI {
toGitUri(uri: Uri, ref: string): Uri;
getRepository(uri: Uri): Repository | null;
init(root: Uri): Promise<Repository | null>;
openRepository(root: Uri): Promise<Repository | null>

registerRemoteSourceProvider(provider: RemoteSourceProvider): Disposable;
registerCredentialsProvider(provider: CredentialsProvider): Disposable;
registerPushErrorHandler(handler: PushErrorHandler): Disposable;
}

export interface GitExtension {
Expand Down Expand Up @@ -264,6 +306,7 @@ export const enum GitErrorCodes {
CantOpenResource = 'CantOpenResource',
GitNotFound = 'GitNotFound',
CantCreatePipe = 'CantCreatePipe',
PermissionDenied = 'PermissionDenied',
CantAccessRemote = 'CantAccessRemote',
RepositoryNotFound = 'RepositoryNotFound',
RepositoryIsLocked = 'RepositoryIsLocked',
Expand All @@ -282,4 +325,4 @@ export const enum GitErrorCodes {
PatchDoesNotApply = 'PatchDoesNotApply',
NoPathFound = 'NoPathFound',
UnknownPath = 'UnknownPath',
}
}
Loading

0 comments on commit 28b7eaa

Please sign in to comment.