Skip to content

Commit 8e3f04f

Browse files
authored
Add extra location for config: .github directory (#652)
Signed-off-by: Sergio Castaño Arteaga <tegioz@icloud.com>
1 parent c8dca34 commit 8e3f04f

2 files changed

Lines changed: 15 additions & 8 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Once the application has been installed we can proceed with its configuration.
1515
To create votes, you'll first need to add a [.gitvote.yml](https://github.com/cncf/gitvote/blob/main/docs/config/.gitvote.yml) configuration file. GitVote will look for it in the following locations (in order of precedence):
1616

1717
- At the root of the repository where the vote was created
18+
- In the `.github` directory of the repository where the vote was created
1819
- At the root of the `.github` repository, for organization wide configuration
1920

2021
> [!IMPORTANT]

src/github.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -348,19 +348,25 @@ impl GH for GHApi {
348348
return None;
349349
};
350350

351-
// Try to get the config file from the repository. Otherwise try
352-
// getting the organization wide config file in the .github repo.
353-
let mut content: Option<String> = None;
354-
for repo in &[repo, ORG_CONFIG_REPO] {
355-
if let Ok(resp) = client.repos(owner, *repo).get_content().path(CONFIG_FILE).send().await
351+
// Check possible locations for configuration file in order of precedence
352+
let config_path = format!(".github/{CONFIG_FILE}");
353+
let candidates = [
354+
// Check repository root.
355+
(repo, CONFIG_FILE),
356+
// Check repository `.github` directory.
357+
(repo, config_path.as_str()),
358+
// Check organization-wide `.github` repository.
359+
(ORG_CONFIG_REPO, CONFIG_FILE),
360+
];
361+
for (repo, path) in candidates {
362+
if let Ok(resp) = client.repos(owner, repo).get_content().path(path).send().await
356363
&& resp.items.len() == 1
357364
{
358-
content = resp.items[0].decoded_content();
359-
break;
365+
return resp.items[0].decoded_content();
360366
}
361367
}
362368

363-
content
369+
None
364370
}
365371

366372
/// [`GH::get_pr_files`]

0 commit comments

Comments
 (0)