cpp-linter / cpp-linter-action

A Github Action for linting C/C++ code integrating clang-tidy and clang-format to collect feedback provided in the form of file-annotations, thread-comments, workflow step-summary, and Pull Request reviews.

Home Page:https://cpp-linter.github.io/cpp-linter-action/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

_pygit2.GitError: repository path '/__w/Waybar/Waybar/' is not owned by current user

zjeffer opened this issue · comments

https://github.com/Alexays/Waybar/actions/runs/7264313349/job/19791578747?pr=2755

When it tries to get the list of source files, it throws this exception:

Get list of specified source files
INFO:CPP Linter:Fetching files list from url: https://api.github.com/repos/Alexays/Waybar/pulls/2755
  Traceback (most recent call last):
    File "/__w/_actions/cpp-linter/cpp-linter-action/main/venv/bin/cpp-linter", line 8, in <module>
      sys.exit(main())
               ^^^^^^
    File "/__w/_actions/cpp-linter/cpp-linter-action/main/venv/lib/python3.11/site-packages/cpp_linter/run.py", line 705, in main
      get_list_of_changed_files()
    File "/__w/_actions/cpp-linter/cpp-linter-action/main/venv/lib/python3.11/site-packages/cpp_linter/run.py", line 153, in get_list_of_changed_files
      Globals.FILES = parse_diff(Globals.response_buffer.text)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/__w/_actions/cpp-linter/cpp-linter-action/main/venv/lib/python3.11/site-packages/cpp_linter/git.py", line 90, in parse_diff
      repo = init_repository(".")
             ^^^^^^^^^^^^^^^^^^^^
    File "/__w/_actions/cpp-linter/cpp-linter-action/main/venv/lib/python3.11/site-packages/pygit2/__init__.py", line 197, in init_repository
      check_error(err)
    File "/__w/_actions/cpp-linter/cpp-linter-action/main/venv/lib/python3.11/site-packages/pygit2/errors.py", line 65, in check_error
      raise GitError(message)
  _pygit2.GitError: repository path '/__w/Waybar/Waybar/' is not owned by current user
  Error: Process completed with exit code 1.

This happened after I moved the installation of dependencies from a separate step in the yaml to the docker image itself:

- name: Install dependencies
  run: |
    apt update 
    apt install sudo python3-pip python3-venv -y

I simply added the 3 packages into the alexays/waybar:debian image (https://github.com/Alexays/Waybar/pull/2742/files)

It used to work when it was still a separate step: https://github.com/zjeffer/Waybar/actions/runs/7194165305/workflow

It's also the first time I'm testing the action on the actual repo (where I don't have write access) instead of my own fork. Could this be the cause?

It's also the first time I'm testing the action on the actual repo (where I don't have write access) instead of my own fork. Could this be the cause?

No. The problem seems more related to the fact that the docker image uses the root user (again).

I think/hope that the solution is to set the parameter mode=pygit2.GIT_REPOSITORY_INIT_SHARED_ALL in the init_repository() call.

Otherwise, we have to go back to parsing the diff string with regex patterns. This was removed to avoid having 2 functions that do the same thing (1 with libgit2 C library, 1 with python string parsing).

I found a way to parse the diff str statically without having to use init_repository(). See cpp-linter/cpp-linter#42.

fix released in v2.7.4

It worked! Thanks for the quick fix!