mirror of
https://github.com/pomber/git-history.git
synced 2024-11-22 23:13:20 +03:00
Add private bitbucket repos
This commit is contained in:
parent
78bff8c9a3
commit
356c7269ad
@ -31,6 +31,7 @@ export function Loading({ repo, path }) {
|
|||||||
export function Error({ error, gitProvider }) {
|
export function Error({ error, gitProvider }) {
|
||||||
const { LogInButton } = gitProvider;
|
const { LogInButton } = gitProvider;
|
||||||
if (error.status === 403) {
|
if (error.status === 403) {
|
||||||
|
// FIX bitbucket uses 403 for private repos
|
||||||
return (
|
return (
|
||||||
<Center>
|
<Center>
|
||||||
<p>
|
<p>
|
||||||
|
@ -14,17 +14,20 @@ function isLoggedIn() {
|
|||||||
|
|
||||||
async function getContent(repo, sha, path) {
|
async function getContent(repo, sha, path) {
|
||||||
const contentResponse = await fetch(
|
const contentResponse = await fetch(
|
||||||
`https://gitlab.com/api/v4/projects/${encodeURIComponent(
|
`https://api.bitbucket.org/2.0/repositories/${repo}/src/${sha}/${path}`,
|
||||||
repo
|
|
||||||
)}/repository/files/${encodeURIComponent(path)}?ref=${sha}`,
|
|
||||||
{ headers: getHeaders() }
|
{ headers: getHeaders() }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (contentResponse.status === 404) {
|
||||||
|
return { content: "" };
|
||||||
|
}
|
||||||
|
|
||||||
if (!contentResponse.ok) {
|
if (!contentResponse.ok) {
|
||||||
throw contentResponse;
|
throw contentResponse;
|
||||||
}
|
}
|
||||||
const contentJson = await contentResponse.json();
|
|
||||||
const content = Base64.decode(contentJson.content);
|
const content = await contentResponse.text();
|
||||||
|
// const content = Base64.decode(contentJson.content);
|
||||||
return { content };
|
return { content };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,21 +86,20 @@ async function getCommits(path, last) {
|
|||||||
avatar: commit.author.user && commit.author.user.links.avatar.href
|
avatar: commit.author.user && commit.author.user.links.avatar.href
|
||||||
},
|
},
|
||||||
commitUrl: commit.links.html.href,
|
commitUrl: commit.links.html.href,
|
||||||
message: commit.message,
|
message: commit.message
|
||||||
content: "foo"
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
const commits = cache[path].slice(0, last);
|
const commits = cache[path].slice(0, last);
|
||||||
|
|
||||||
// await Promise.all(
|
await Promise.all(
|
||||||
// commits.map(async commit => {
|
commits.map(async commit => {
|
||||||
// if (!commit.content) {
|
if (!commit.content) {
|
||||||
// const info = await getContent(repo, commit.sha, path);
|
const info = await getContent(repo, commit.sha, path);
|
||||||
// commit.content = info.content;
|
commit.content = info.content;
|
||||||
// }
|
}
|
||||||
// })
|
})
|
||||||
// );
|
);
|
||||||
|
|
||||||
return commits;
|
return commits;
|
||||||
}
|
}
|
||||||
@ -107,10 +109,7 @@ function logIn() {
|
|||||||
var authenticator = new netlify({
|
var authenticator = new netlify({
|
||||||
site_id: "ccf3a0e2-ac06-4f37-9b17-df1dd41fb1a6"
|
site_id: "ccf3a0e2-ac06-4f37-9b17-df1dd41fb1a6"
|
||||||
});
|
});
|
||||||
authenticator.authenticate({ provider: "gitlab", scope: "api" }, function(
|
authenticator.authenticate({ provider: "bitbucket" }, function(err, data) {
|
||||||
err,
|
|
||||||
data
|
|
||||||
) {
|
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
return;
|
return;
|
||||||
@ -127,7 +126,7 @@ function LogInButton() {
|
|||||||
onClick={logIn}
|
onClick={logIn}
|
||||||
style={{ fontWeight: 600, padding: "0.5em 0.7em", cursor: "pointer" }}
|
style={{ fontWeight: 600, padding: "0.5em 0.7em", cursor: "pointer" }}
|
||||||
>
|
>
|
||||||
<div>Sign in with GitLab</div>
|
<div>Sign in with Bitbucket</div>
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,9 @@ export default function getGitProvider() {
|
|||||||
const [cloud] = window.location.host.split(".");
|
const [cloud] = window.location.host.split(".");
|
||||||
if (cloud === "gitlab") {
|
if (cloud === "gitlab") {
|
||||||
return gitlabProvider;
|
return gitlabProvider;
|
||||||
}
|
} else if (cloud === "bitbucket") {
|
||||||
return bitbucketProvider;
|
return bitbucketProvider;
|
||||||
|
}
|
||||||
return githubProvider;
|
return githubProvider;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user