Skip to content

Commit 5003462

Browse files
Merge pull request #96
Added global file search in personal repository
2 parents 332f5ef + 275ea5d commit 5003462

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

src/utils/config.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ export const readConfig = async (
1414
): Promise<Config> => {
1515
const content: string = readFile(config, userConfigPath);
1616

17-
const remoteConfig: Config = await readRemoteConfig(repo, userConfigPath);
17+
const remoteConfig: Config = await readRemoteConfig(
18+
config,
19+
repo,
20+
userConfigPath,
21+
);
1822

1923
if (content === "") {
2024
return <Config>merge(defaultConfig, remoteConfig, config);
@@ -26,6 +30,7 @@ export const readConfig = async (
2630
};
2731

2832
export const readRemoteConfig = async (
33+
config: Config,
2934
repo: Repository | undefined,
3035
filename: string,
3136
): Promise<Config> => {
@@ -34,10 +39,19 @@ export const readRemoteConfig = async (
3439
return <Config>{};
3540
}
3641

37-
const response: string = await repo.getRawFile(filename);
42+
const response1: string = await repo.getRawFile(".github", filename);
43+
44+
if (response1 !== "") {
45+
return <Config>yaml.load(response1);
46+
}
47+
48+
const response2: string = await repo.getRawFile(
49+
config.repository?.owner || ".github",
50+
filename,
51+
);
3852

39-
if (response !== "") {
40-
return <Config>yaml.load(response);
53+
if (response2 !== "") {
54+
return <Config>yaml.load(response2);
4155
}
4256

4357
return <Config>{};

src/utils/repository.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,13 @@ export class Repository {
202202
}
203203
}
204204

205-
async getRawFile(filename: string): Promise<string> {
205+
async getRawFile(repo: string, filename: string): Promise<string> {
206206
try {
207207
const response = await this._octokit.rest.repos.getContent(<
208208
RestEndpointMethodTypes["repos"]["getContent"]["parameters"]
209209
>{
210210
owner: this._config.repository?.owner,
211-
repo: ".github",
211+
repo: repo,
212212
path: filename,
213213
headers: {
214214
Accept: "application/vnd.github.v3.raw",

0 commit comments

Comments
 (0)