AutoPR icon indicating copy to clipboard operation
AutoPR copied to clipboard

Extract branch name into a separate variable in the workflow yaml

Open shuplenkov opened this issue 2 years ago • 1 comments

If I use master branch, instead of main (ref: main was changed to ref: master), I have this error:

Starting main                  repo_path=/github/workspace settings=GitHubActionSettings(pull_request_agent_id='rail-v1', pull_request_agent_config=None, codegen_agent_id='auto-v1', codegen_agent_config=None, brain_agent_id='simple-v1', brain_agent_config=None, base_branch='main', target_branch_name_template='autopr/{issue_number}', loading_gif_url='https://media0.giphy.com/media/l3nWhI38IWDofyDrW/giphy.gif', model='gpt-4', temperature=0.8, rail_temperature=0.4, context_limit=8192, min_tokens=1000, max_tokens=2000, num_reasks=2)
Checking out main...
Traceback (most recent call last):
  File "/venv/lib/python3.9/site-packages/git/util.py", line 1095, in __getitem__
    return getattr(self, index)
  File "/venv/lib/python3.9/site-packages/git/util.py", line 1083, in __getattr__
    return list.__getattribute__(self, attr)
AttributeError: 'IterableList' object has no attribute 'main'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/app/autopr/gh_actions_entrypoint.py", line 94, in <module>
    main(
  File "/app/autopr/main.py", line 63, in main
    repo.heads[settings.base_branch].checkout()
  File "/venv/lib/python3.9/site-packages/git/util.py", line 1097, in __getitem__
    raise IndexError("No item found with id %r" % (self._prefix + index)) from e
IndexError: No item found with id 'main'

It looks like it is still trying to use main instead of master.

shuplenkov avatar May 04 '23 15:05 shuplenkov

The first line of the log shows base_branch='main'. You probably just changed the main to master in the actions/checkout@v2 step. What you need to do is also add it to AutoPR's with: block, as such:

      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}
        base_branch: master

Perhaps the base branch should be abstracted out as an environment variable in the yaml.

irgolic avatar May 04 '23 16:05 irgolic