Skip to content

Commit

Permalink
Merge pull request #476 from conwnet/master
Browse files Browse the repository at this point in the history
release 0.11.0
  • Loading branch information
conwnet authored Jan 20, 2023
2 parents 3efd423 + 042eb4a commit c6fb771
Show file tree
Hide file tree
Showing 22 changed files with 732 additions and 468 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ We are partnered with [OSS Insight](https://ossinsight.io/?utm_source=github1s&u

## Stargazers over time

[![Stargazers over time](https://starchart.cc/conwnet/github1s.svg)](https://starchart.cc/conwnet/github1s)
[![Stargazers over time](https://api.star-history.com/svg?repos=conwnet/github1s&type=Date)](https://star-history.com/#conwnet/github1s&Date)

<details>
<summary>Third-party Related Projects</summary>
Expand Down
1 change: 1 addition & 0 deletions api/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
2 changes: 1 addition & 1 deletion api/vscode-unpkg/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import got from 'got';
import * as url from 'url';
import type { VercelRequest, VercelResponse } from '@vercel/node';

module.exports = async (req: VercelRequest, res: VercelResponse) => {
export default async (req: VercelRequest, res: VercelResponse) => {
const pathname = url.parse(req.url || '').pathname || '';
const matches = pathname.match(/^\/api\/vscode-unpkg\/([^/]+)\/(.*)/);

Expand Down
2 changes: 1 addition & 1 deletion extensions/github1s/src/adapters/github1s/parse-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const parsePullUrl = async (path: string): Promise<RouterState> => {
return {
repo: `${owner}/${repo}`,
pageType: PageType.CodeReview,
ref: codeReview.base.commitSha,
ref: codeReview.head.commitSha,
codeReviewId,
};
};
Expand Down
14 changes: 7 additions & 7 deletions extensions/github1s/src/adapters/ossinsight/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ const createRepoItemMarkdown = (repo: RepoItem, period: RankingPeriod) => {
return `[${username}](https://github.com/${username})`;
});
const repoBadges = [
`![Language](https://img.shields.io/github/languages/top/${repo.repo_name})`,
`![Watch](https://img.shields.io/github/watchers/${repo.repo_name}?label=Watch)`,
`![Fork](https://img.shields.io/github/forks/${repo.repo_name}?label=Fork)`,
`![Star](https://img.shields.io/github/stars/${repo.repo_name}?label=Star)`,
`![LastCommit](https://img.shields.io/github/last-commit/${repo.repo_name})`,
`[![Language](https://img.shields.io/github/languages/top/${repo.repo_name})](https://github.com/${repo.repo_name})`,
`[![Watch](https://img.shields.io/github/watchers/${repo.repo_name}?label=Watch)](https://github.com/${repo.repo_name}/watchers)`,
`[![Fork](https://img.shields.io/github/forks/${repo.repo_name}?label=Fork)](https://github.com/${repo.repo_name}/forks)`,
`[![Star](https://img.shields.io/github/stars/${repo.repo_name}?label=Star)](https://github.com/${repo.repo_name}/stargazers)`,
`[![LastCommit](https://img.shields.io/github/last-commit/${repo.repo_name})](https://github.com/${repo.repo_name}/commits)`,
];

const increaseStarsText = (repo.stars || 0) >= 0 ? `+${repo.stars || 0}` : `-${repo.stars}`;
const increaseForksText = (repo.forks || 0) >= 0 ? `+${repo.forks || 0}` : `-${repo.forks}`;
const contributorsMardown = contributorAvatars.length
const contributorsMarkdown = contributorAvatars.length
? ' &nbsp;&nbsp; Built by &nbsp;' + contributorAvatars.join('&nbsp;&nbsp;')
: '';
const collectionMarkdown = repo.collection_names ? ` &nbsp;&nbsp; <i>${repo.collection_names}</i>` : '';
Expand All @@ -47,7 +47,7 @@ const createRepoItemMarkdown = (repo: RepoItem, period: RankingPeriod) => {
${repo.description || ''}
⭐️ ${increaseStarsText} &nbsp;&nbsp; 🔗 ${increaseForksText} ${contributorsMardown}${collectionMarkdown}
⭐️ ${increaseStarsText} &nbsp;&nbsp; 🔗 ${increaseForksText} ${contributorsMarkdown}${collectionMarkdown}
${repoBadges.join('&nbsp;')}
`;
Expand Down
4 changes: 3 additions & 1 deletion extensions/github1s/src/changes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import * as vscode from 'vscode';
import * as adapterTypes from '@/adapters/types';
import { GitHub1sQuickDiffProvider } from './quick-diff';
import { getChangedFileDiffCommand, getChangedFiles } from './files';
import adapterManager from '@/adapters/manager';

export const updateSourceControlChanges = (() => {
const sourceControl = vscode.scm.createSourceControl('github1s', 'GitHub1s');
const rootUri = vscode.Uri.parse('').with({ scheme: adapterManager.getCurrentScheme() });
const sourceControl = vscode.scm.createSourceControl('github1s', 'GitHub1s', rootUri);
const changesGroup = sourceControl.createResourceGroup('changes', 'Changes');
sourceControl.quickDiffProvider = new GitHub1sQuickDiffProvider();

Expand Down
45 changes: 26 additions & 19 deletions extensions/github1s/src/changes/quick-diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,30 @@

import * as vscode from 'vscode';
import router from '@/router';
import { Repository } from '@/repository';
import { emptyFileUri } from '@/providers';
import adapterManager from '@/adapters/manager';
import * as adapterTypes from '@/adapters/types';

// get the original source uri when the `routerState.pageType` is `PageType.PULL`
const getOriginalResourceForPull = async (uri: vscode.Uri, codeReviewId: string): Promise<vscode.Uri | null> => {
const routeState = await router.getState();
const dataSource = await adapterManager.getCurrentAdapter().resolveDataSource();
const codeReview = await dataSource.provideCodeReview(routeState.repo, codeReviewId);
const changedFile = codeReview?.files?.find((changedFile) => changedFile.path === uri.path.slice(1));

// TODO: why removed
if (!changedFile || changedFile.status === adapterTypes.FileChangeStatus.Removed) {
const currentScheme = adapterManager.getCurrentScheme();
const repository = Repository.getInstance(currentScheme, routeState.repo);
const codeReviewFiles = await repository.getCodeReviewChangedFiles(codeReviewId);
const changedFile = codeReviewFiles?.find((changedFile) => changedFile.path === uri.path.slice(1));

if (
!changedFile ||
changedFile.status === adapterTypes.FileChangeStatus.Added ||
changedFile.status === adapterTypes.FileChangeStatus.Removed
) {
return null;
}

if (changedFile.status === adapterTypes.FileChangeStatus.Added) {
return emptyFileUri;
const codeReview = await repository.getCodeReviewItem(codeReviewId);
if (!codeReview?.base?.commitSha) {
return null;
}

const originalAuthority = `${routeState.repo}+${codeReview!.base.commitSha}`;
Expand All @@ -34,20 +40,21 @@ const getOriginalResourceForPull = async (uri: vscode.Uri, codeReviewId: string)
// get the original source uri when the `routerState.pageType` is `PageType.COMMIT`
const getOriginalResourceForCommit = async (uri: vscode.Uri, commitSha: string) => {
const routeState = await router.getState();
const dataSource = await adapterManager.getCurrentAdapter().resolveDataSource();
const commit = await dataSource.provideCommit(routeState.repo, commitSha);
const changedFile = commit?.files?.find((changedFile) => changedFile.path === uri.path.slice(1));

if (!changedFile || changedFile.status === adapterTypes.FileChangeStatus.Removed) {
const currentScheme = adapterManager.getCurrentScheme();
const repository = Repository.getInstance(currentScheme, routeState.repo);
const commitFiles = await repository.getCommitChangedFiles(commitSha);
const changedFile = commitFiles?.find((changedFile) => changedFile.path === uri.path.slice(1));

if (
!changedFile ||
changedFile.status === adapterTypes.FileChangeStatus.Added ||
changedFile.status === adapterTypes.FileChangeStatus.Removed
) {
return null;
}

if (changedFile.status === adapterTypes.FileChangeStatus.Added) {
return emptyFileUri;
}

const parentCommitSha = commit!.parents?.[0] || 'HEAD';

const commit = await repository.getCommitItem(commitSha);
const parentCommitSha = commit?.parents?.[0];
if (!parentCommitSha) {
return emptyFileUri;
}
Expand Down
6 changes: 3 additions & 3 deletions extensions/github1s/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -681,9 +681,9 @@ dayjs@^1.11.1:
integrity sha512-F4LXf1OeU9hrSYRPTTj/6FbO4HTjPKXvEIC1P2kcnFurViINCVk3ZV0xAS3XVx9MkMsXbbqlK6hjseaYbgKEHw==

decode-uri-component@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545"
integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=
version "0.2.2"
resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.2.tgz#e69dbe25d37941171dd540e024c444cd5188e1e9"
integrity sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ==

define-properties@^1.1.3, define-properties@^1.1.4:
version "1.1.4"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"lib": "lib"
},
"devDependencies": {
"@github1s/vscode-web": "0.6.0",
"@github1s/vscode-web": "0.7.0",
"@typescript-eslint/eslint-plugin": "^5.40.1",
"@typescript-eslint/parser": "^5.40.1",
"chokidar": "^3.5.3",
Expand Down
12 changes: 6 additions & 6 deletions tests/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1297,9 +1297,9 @@ decimal.js@^10.2.1:
integrity sha512-V0pfhfr8suzyPGOx3nmq4aHqabehUZn6Ch9kyFpV79TGDTWFmHqUqXdabR7QHqxzrYolF4+tVmJhUG4OURg5dQ==

decode-uri-component@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545"
integrity sha512-hjf+xovcEn31w/EUYdTXQh/8smFL/dzYjohQGEIgjyNavaJfBY2p5F527Bo1VPATxv0VYTUC2bOcXvqFwk78Og==
version "0.2.2"
resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.2.tgz#e69dbe25d37941171dd540e024c444cd5188e1e9"
integrity sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ==

deep-is@~0.1.3:
version "0.1.4"
Expand Down Expand Up @@ -2725,9 +2725,9 @@ json-parse-even-better-errors@^2.3.0:
integrity sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==

[email protected], json5@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.1.tgz#655d50ed1e6f95ad1a3caababd2b0efda10b395c"
integrity sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==
version "2.2.3"
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283"
integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==

kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0:
version "3.2.2"
Expand Down
2 changes: 1 addition & 1 deletion vscode-web/.VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.72.1
1.74.3
14 changes: 7 additions & 7 deletions vscode-web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@github1s/vscode-web",
"version": "0.5.0",
"version": "0.7.0",
"description": "VS Code web for GitHub1s",
"author": "github1s",
"license": "MIT",
Expand Down Expand Up @@ -32,13 +32,13 @@
"@vscode/vscode-languagedetection": "1.0.21",
"jschardet": "3.0.0",
"tas-client-umd": "0.1.6",
"vscode-oniguruma": "1.6.1",
"vscode-oniguruma": "1.7.0",
"vscode-textmate": "7.0.1",
"xterm": "5.1.0-beta.15",
"xterm-addon-canvas": "0.3.0-beta.1",
"xterm-addon-search": "0.11.0-beta.1",
"xterm-addon-unicode11": "0.5.0-beta.1",
"xterm-addon-webgl": "0.14.0-beta.8"
"xterm": "5.1.0-beta.63",
"xterm-addon-canvas": "0.3.0-beta.27",
"xterm-addon-search": "0.11.0-beta.7",
"xterm-addon-unicode11": "0.5.0-beta.5",
"xterm-addon-webgl": "0.14.0-beta.40"
},
"devDependencies": {
"@types/trusted-types": "^2.0.0",
Expand Down
Loading

1 comment on commit c6fb771

@vercel
Copy link

@vercel vercel bot commented on c6fb771 Jan 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.