-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
As noted in #20117, we only use pathdiff
for one relativize_path_to
call in our GitLab output format. This was added in #3475 to make the GitLab output relative to the CI_PROJECT_DIR
environment variable. According to the docs, this is a pre-defined variable with this description:
The full path the repository is cloned to, and where the job runs from. If the GitLab Runner
builds_dir
parameter is set, this variable is set relative to the value ofbuilds_dir
. For more information, see the Advanced GitLab Runner configuration.
In my simple test repo, echoing $CI_PROJECT_DIR
and pwd
shows that the job starts out in this directory, as stated above:
$ echo $CI_PROJECT_DIR
/builds/nothanks3/test-gitlab-output-format
$ pwd
/builds/nothanks3/test-gitlab-output-format
$ ruff --version
ruff 0.12.8
$ ruff check --output-format=gitlab > code-quality-report.json
For basic usage like this, it seems fine then to drop relativize_path_to
and pathdiff
in favor of the fallback handling that makes the path relative to the CWD. In fact, this was the behavior before #1837, which made GitLab paths absolute. I'm just slightly concerned that this could break users with more adventurous directory changes in their CI jobs.
We could also use our own relativize_path
function in render.rs
, but the behavior seems to be a bit different from pathdiff::diff_paths
if the base directory isn't a prefix of the path. diff_paths
will add ..
components in this case.
This is the only function we use from pathdiff
, so yet another option is vendoring just that.