- improve formatting

- add some more comments
This commit is contained in:
Mike Penz
2023-11-05 10:30:10 +00:00
committed by GitHub
parent 2538eab26b
commit 0e00e184e7
6 changed files with 23 additions and 10 deletions
Generated Vendored
+12 -7
View File
@@ -1764,6 +1764,9 @@ class GiteaRepository extends BaseRepository_1.BaseRepository {
get defaultUrl() {
return 'https://gitea.com';
}
get homeUrl() {
return 'https://gitea.com';
}
constructor(token, url, repositoryPath) {
super(token, url, repositoryPath);
this.mapComment = (comment) => {
@@ -1830,6 +1833,10 @@ class GiteaRepository extends BaseRepository_1.BaseRepository {
reviews: undefined
};
}
/**
* WARNING: This does not actually get the diff from the remote, as Gitea does not offer a compareable API.
* This uses the local repository to get the diff. NOTE: As such, gitea integration requires the repo available.
*/
getDiffRemote(owner, repo, base, head) {
return __awaiter(this, void 0, void 0, function* () {
let changedFilesCount = 0;
@@ -1952,7 +1959,7 @@ class GiteaRepository extends BaseRepository_1.BaseRepository {
getTags(owner, repo, maxTagsToFetch) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
core.debug(`start to get gitea tag `);
core.debug(`Start to get tag from gitea`);
const response = yield this.api.repos.repoListTags(owner, repo, {
limit: maxTagsToFetch
});
@@ -1972,9 +1979,6 @@ class GiteaRepository extends BaseRepository_1.BaseRepository {
return tagsInfo;
});
}
get homeUrl() {
return 'https://gitea.com';
}
}
exports.GiteaRepository = GiteaRepository;
GiteaRepository.pulls = {
@@ -2254,6 +2258,10 @@ class GithubRepository extends BaseRepository_1.BaseRepository {
get defaultUrl() {
return 'https://api.github.com';
}
get homeUrl() {
var _a;
return ((_a = this.url) === null || _a === void 0 ? void 0 : _a.replace('api.', '')) || 'https://github.com';
}
constructor(token, url, repositoryPath) {
super(token, url, repositoryPath);
this.mapPullRequest = (pr, status = 'open') => {
@@ -2384,9 +2392,6 @@ class GithubRepository extends BaseRepository_1.BaseRepository {
}
return false;
}
get homeUrl() {
return 'https://github.com';
}
}
exports.GithubRepository = GithubRepository;
Generated Vendored
+1 -1
View File
File diff suppressed because one or more lines are too long
+2
View File
@@ -12,7 +12,9 @@ export abstract class BaseRepository {
// Define an abstract getter for the default URL
abstract get defaultUrl(): string
// Define the abstract getter for the home URL (also used for some replace patterns)
abstract get homeUrl(): string
protected constructor(
protected token: string,
protected url: string | undefined,
+6 -1
View File
@@ -6,6 +6,7 @@ import {Api, PullRequest, PullReview, giteaApi} from 'gitea-js'
import moment from 'moment'
import * as core from '@actions/core'
import {createCommandManager} from '../pr-collector/gitHelper'
interface Pulls {
closed: PullRequest[]
open: PullRequest[]
@@ -85,6 +86,10 @@ export class GiteaRepository extends BaseRepository {
}
}
/**
* WARNING: This does not actually get the diff from the remote, as Gitea does not offer a compareable API.
* This uses the local repository to get the diff. NOTE: As such, gitea integration requires the repo available.
*/
async getDiffRemote(owner: string, repo: string, base: string, head: string): Promise<DiffInfo> {
let changedFilesCount = 0
let additionCount = 0
@@ -223,7 +228,7 @@ export class GiteaRepository extends BaseRepository {
})
async getTags(owner: string, repo: string, maxTagsToFetch: number): Promise<TagInfo[]> {
core.debug(`start to get gitea tag `)
core.debug(`Start to get tag from gitea`)
const response = await this.api.repos.repoListTags(owner, repo, {
limit: maxTagsToFetch
})
+1
View File
@@ -288,6 +288,7 @@ export class GithubRepository extends BaseRepository {
body: comment.body,
state: comment.state
})
private fetchedEnough(pullRequests: PullsListData, fromDate: moment.Moment): boolean {
for (let i = 0; i < Math.min(pullRequests.length, 3); i++) {
const firstPR = pullRequests[i]