mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-06-11 09:57:48 +02:00
feat(#200): save the commit date of the anonymized commit
This commit is contained in:
@@ -3,7 +3,12 @@
|
|||||||
<div class="leftCol shadow p-1 overflow-auto" ng-show="files">
|
<div class="leftCol shadow p-1 overflow-auto" ng-show="files">
|
||||||
<tree class="files" file="files"></tree>
|
<tree class="files" file="files"></tree>
|
||||||
<div class="bottom column">
|
<div class="bottom column">
|
||||||
<div class="last-update">
|
<div
|
||||||
|
class="last-update"
|
||||||
|
data-toggle="tooltip"
|
||||||
|
data-placement="top"
|
||||||
|
title="{{options.lastUpdateDate}}"
|
||||||
|
>
|
||||||
Last Update: {{options.lastUpdateDate|date}}
|
Last Update: {{options.lastUpdateDate|date}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+13
-1
@@ -191,9 +191,10 @@ export default class Repository {
|
|||||||
) {
|
) {
|
||||||
// Only GitHubBase can be update for the moment
|
// Only GitHubBase can be update for the moment
|
||||||
if (this.source instanceof GitHubBase) {
|
if (this.source instanceof GitHubBase) {
|
||||||
|
const token = await this.source.getToken();
|
||||||
const branches = await this.source.githubRepository.branches({
|
const branches = await this.source.githubRepository.branches({
|
||||||
force: true,
|
force: true,
|
||||||
accessToken: await this.source.getToken(),
|
accessToken: token,
|
||||||
});
|
});
|
||||||
const branch = this.source.branch;
|
const branch = this.source.branch;
|
||||||
const newCommit = branches.filter((f) => f.name == branch.name)[0]
|
const newCommit = branches.filter((f) => f.name == branch.name)[0]
|
||||||
@@ -203,6 +204,17 @@ export default class Repository {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._model.source.commit = newCommit;
|
this._model.source.commit = newCommit;
|
||||||
|
const commitInfo = await this.source.githubRepository.getCommitInfo(
|
||||||
|
newCommit,
|
||||||
|
{
|
||||||
|
accessToken: token,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
if (commitInfo.commit.author?.date) {
|
||||||
|
this._model.source.commitDate = new Date(
|
||||||
|
commitInfo.commit.author?.date
|
||||||
|
);
|
||||||
|
}
|
||||||
branch.commit = newCommit;
|
branch.commit = newCommit;
|
||||||
|
|
||||||
if (!newCommit) {
|
if (!newCommit) {
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ const AnonymizedRepositorySchema = new Schema({
|
|||||||
type: { type: String },
|
type: { type: String },
|
||||||
branch: String,
|
branch: String,
|
||||||
commit: String,
|
commit: String,
|
||||||
|
commitDate: Date,
|
||||||
repositoryId: String,
|
repositoryId: String,
|
||||||
repositoryName: String,
|
repositoryName: String,
|
||||||
accessToken: String,
|
accessToken: String,
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ export interface IAnonymizedRepository {
|
|||||||
type: "GitHubDownload" | "GitHubStream" | "Zip";
|
type: "GitHubDownload" | "GitHubStream" | "Zip";
|
||||||
branch?: string;
|
branch?: string;
|
||||||
commit?: string;
|
commit?: string;
|
||||||
|
commitDate?: Date,
|
||||||
repositoryId?: string;
|
repositoryId?: string;
|
||||||
repositoryName?: string;
|
repositoryName?: string;
|
||||||
accessToken?: string;
|
accessToken?: string;
|
||||||
|
|||||||
@@ -153,7 +153,9 @@ router.get(
|
|||||||
res.json({
|
res.json({
|
||||||
url: redirectURL,
|
url: redirectURL,
|
||||||
download,
|
download,
|
||||||
lastUpdateDate: repo.model.statusDate,
|
lastUpdateDate: repo.model.source.commitDate
|
||||||
|
? repo.model.source.commitDate
|
||||||
|
: repo.model.anonymizeDate,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleError(error, res, req);
|
handleError(error, res, req);
|
||||||
|
|||||||
@@ -44,6 +44,21 @@ export class GitHubRepository {
|
|||||||
return this._data.size;
|
return this._data.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getCommitInfo(
|
||||||
|
sha: string,
|
||||||
|
opt: {
|
||||||
|
accessToken?: string;
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
const octokit = new Octokit({ auth: opt.accessToken });
|
||||||
|
const commit = await octokit.repos.getCommit({
|
||||||
|
owner: this.owner,
|
||||||
|
repo: this.repo,
|
||||||
|
ref: sha,
|
||||||
|
});
|
||||||
|
return commit.data;
|
||||||
|
}
|
||||||
|
|
||||||
async branches(opt: {
|
async branches(opt: {
|
||||||
accessToken?: string;
|
accessToken?: string;
|
||||||
force?: boolean;
|
force?: boolean;
|
||||||
|
|||||||
Reference in New Issue
Block a user