Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support github commit #238

Merged
merged 1 commit into from
Mar 20, 2021
Merged

feat: support github commit #238

merged 1 commit into from
Mar 20, 2021

Conversation

conwnet
Copy link
Owner

@conwnet conwnet commented Mar 20, 2021

Support the url looks like https://github.com/conwnet/github1s/commit/39f10618df450771389d01bc88d117deaf79eedf
#236

@vercel
Copy link

vercel bot commented Mar 20, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/vscode-github1s/github1s/C64vs1ZQNwCdb4MmZ1PnhJRuydHJ
✅ Preview: https://github1s-git-feature-commit-vscode-github1s.vercel.app

Copy link
Collaborator

@Siddhant-K-code Siddhant-K-code left a comment

Choose a reason for hiding this comment

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

LGTM!

@conwnet conwnet merged commit daa6049 into master Mar 20, 2021
Comment on lines 83 to +90
private constructor() {
this._branchRefsMap = new Map();
this._tagRefsMap = new Map();
this._pullsMap = new Map();
this._pullMap = new Map();
this._pullFilesMap = new Map();
this._commitMap = new Map();
this._commitFilesMap = new Map();
Copy link
Collaborator

Choose a reason for hiding this comment

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

We might need to consolidate the maps into two maps, since the maps are used as cache layers.

I think we should adopt a HTTP request client or invent a cache level on the network call side instead of put maps here.

For example, if we leverage the Got, which has built-in cache support:
https://github.com/sindresorhus/got#cache-adapters

We could remove all the maps and this file can be significantly simplified.

for example

	public getCommit = reuseable(
		async (
			commitSha: string,
			forceUpdate: boolean = false
		): Promise<RepositoryCommit> => {
			const [owner, repo] = [this.getOwner(), this.getRepo()];
			const key = `${owner}+${repo}+${commitSha}`;

			if (!this._commitMap.has(key) || forceUpdate) {
				const commitData = (await getGitHubCommitDetail(
					owner,
					repo,
					commitSha
				)) as RepositoryCommit;
				this._commitMap.set(key, commitData);
				this._commitFilesMap.set(key, commitData.files);
			}

			return this._commitMap.get(key);
		}
	);

->

	public getCommit = reuseable(
		async (
			commitSha: string,
			forceUpdate: boolean = false
		): Promise<RepositoryCommit> => {
			const [owner, repo] = [this.getOwner(), this.getRepo()];
			return getGitHubCommitDetail(
				owner,
				repo,
				commitSha
			) as Promise<RepositoryCommit>;
		}
	);

@conwnet conwnet deleted the feature/commit branch March 21, 2021 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants