-
+
Last Update: {{options.lastUpdateDate|date}}
diff --git a/src/Repository.ts b/src/Repository.ts
index 46c688c..979b396 100644
--- a/src/Repository.ts
+++ b/src/Repository.ts
@@ -191,9 +191,10 @@ export default class Repository {
) {
// Only GitHubBase can be update for the moment
if (this.source instanceof GitHubBase) {
+ const token = await this.source.getToken();
const branches = await this.source.githubRepository.branches({
force: true,
- accessToken: await this.source.getToken(),
+ accessToken: token,
});
const branch = this.source.branch;
const newCommit = branches.filter((f) => f.name == branch.name)[0]
@@ -203,6 +204,17 @@ export default class Repository {
return;
}
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;
if (!newCommit) {
diff --git a/src/database/anonymizedRepositories/anonymizedRepositories.schema.ts b/src/database/anonymizedRepositories/anonymizedRepositories.schema.ts
index 9756bfe..d77e922 100644
--- a/src/database/anonymizedRepositories/anonymizedRepositories.schema.ts
+++ b/src/database/anonymizedRepositories/anonymizedRepositories.schema.ts
@@ -25,6 +25,7 @@ const AnonymizedRepositorySchema = new Schema({
type: { type: String },
branch: String,
commit: String,
+ commitDate: Date,
repositoryId: String,
repositoryName: String,
accessToken: String,
diff --git a/src/database/anonymizedRepositories/anonymizedRepositories.types.ts b/src/database/anonymizedRepositories/anonymizedRepositories.types.ts
index b01600e..ba74778 100644
--- a/src/database/anonymizedRepositories/anonymizedRepositories.types.ts
+++ b/src/database/anonymizedRepositories/anonymizedRepositories.types.ts
@@ -11,6 +11,7 @@ export interface IAnonymizedRepository {
type: "GitHubDownload" | "GitHubStream" | "Zip";
branch?: string;
commit?: string;
+ commitDate?: Date,
repositoryId?: string;
repositoryName?: string;
accessToken?: string;
diff --git a/src/routes/repository-public.ts b/src/routes/repository-public.ts
index a266421..140190a 100644
--- a/src/routes/repository-public.ts
+++ b/src/routes/repository-public.ts
@@ -153,7 +153,9 @@ router.get(
res.json({
url: redirectURL,
download,
- lastUpdateDate: repo.model.statusDate,
+ lastUpdateDate: repo.model.source.commitDate
+ ? repo.model.source.commitDate
+ : repo.model.anonymizeDate,
});
} catch (error) {
handleError(error, res, req);
diff --git a/src/source/GitHubRepository.ts b/src/source/GitHubRepository.ts
index 8047492..12c3e40 100644
--- a/src/source/GitHubRepository.ts
+++ b/src/source/GitHubRepository.ts
@@ -44,6 +44,21 @@ export class GitHubRepository {
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: {
accessToken?: string;
force?: boolean;