context.config reads from primary branch, not current commit
See original GitHub issueBug Report
Current Behavior
context.config()
reads the configuration from the primary branch (i.e. master) rather than the current commit.
- Create branch in current repo
- Add a
.github/testconfig.yml
with some non-default configuration - Commit it to the new branch, and push
- Open a pull request
// Your code here
module.exports = robot => {
robot.on('pull_request.opened', async context => {
console.log(await context.config('testconfig.yml'));
});
}
Expected behavior/code
The changes made in the pull request should apply to any events run for that pull request (including pull_request
, check_suite
, check_run
, etc).
Environment
- Probot version(s): 6.1.0
- Node/npm version: n/a
- OS: n/a
Possible Solution
When fetching the content of the file, add the additional optional ref parameter. (Possibly via a flag to context.config
.)
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:8 (6 by maintainers)
Top Results From Across the Web
There is no tracking information for the current branch
This happens due to current branch has no tracking on the branch on the remote. so you can do it ... git branch...
Read more >Git - git-config Documentation
If the repository configuration file is missing or unreadable, git config will exit with a non-zero error code. An error message is produced...
Read more >Apply changes from one Git branch to another
Select the branch that you want to merge into the current branch, click Modify options and choose from the following: --no-ff : a...
Read more >Configuring CircleCI
See Workflows for configuring branch execution for jobs in a workflow or 2.1 ... This is because the primary container is typically used...
Read more >git rebase | Atlassian Git Tutorial
This page will take a more detailed look at git rebase configuration and execution ... You want to get the latest updates to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think it makes sense for the default to be master, but it entirely depends on what sort of bot you’re writing. A lot of the probot-based bots I see are related to meta-level things in the repository, and those make sense to use the default branch. However, the bot that I’m primarily working on is for build tools. For things like this, you want to use the config for the specific branch, allowing you to change build rules and see what the result is before merging.
Creating a test repo to try a different build config makes no sense, but it is sensible for repo-level configuration. Making probot a tool only to handle the latter would exclude a lot of use cases. 😃
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.