Problem/Motivation

Currently core/scripts/dev/commit-code-check.sh is broken on DrupalCI due git security improvements and our CI. Let's fix this.

It fails due to:

16:35:03 Container command.
16:35:03 core/scripts/dev/commit-code-check.sh --drupalci
16:35:03 fatal: detected dubious ownership in repository at '/var/www/html'
16:35:03 To add an exception for this directory, call:
16:35:03 
16:35:03 	git config --global --add safe.directory /var/www/html
16:35:03 Creating list of files to check by comparing branch to 10.1.x
16:35:03 error: Could not access 'HEAD~1'
16:35:03 fatal: detected dubious ownership in repository at '/var/www/html'
16:35:03 To add an exception for this directory, call:
16:35:03 
16:35:03 	git config --global --add safe.directory /var/www/html
16:35:03 There are no files to check. If you have staged a commit use the --cached option.

https://dispatcher.drupalci.org/job/drupal8_core_regression_tests/77420/...

Proposed resolution

I think using the www-data to run git commands.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#2 3343495-2.patch1.98 KBalexpott

Comments

alexpott created an issue. See original summary.

alexpott’s picture

Status: Active » Needs review
StatusFileSize
new1.98 KB
alexpott’s picture

The patch in #2 works nicely...

20:59:48 Directory created at /var/lib/drupalci/workspace/jenkins-drupal_patches-168161/ancillary/container_command.commit-checks
20:59:48 Container command.
20:59:48 core/scripts/dev/commit-code-check.sh --drupalci
21:00:07 1/1 ./scripts/dev/commit-code-check.sh 702.78ms
21:00:08 CSpell: Files checked: 1, Issues found: 0 in 0 files
21:00:08 
21:00:08 CSpell: passed
lauriii’s picture

Status: Needs review » Reviewed & tested by the community

Fix is pretty interesting but I think I remember seeing this when working on DrupalCI so it’s a pre-existing thing. Works for me given that tests pass.

alexpott’s picture

I've run phpstan, phpcs, cspell, prettier, stylelint, eslint and it is all passing.

  • larowlan committed b7dc1791 on 10.0.x
    Issue #3343495 by alexpott: Fix commit-code-check.sh on DrupalCI
    
    (...

  • larowlan committed 65d49c9c on 10.1.x
    Issue #3343495 by alexpott: Fix commit-code-check.sh on DrupalCI
    

  • larowlan committed 846a66c0 on 9.4.x
    Issue #3343495 by alexpott: Fix commit-code-check.sh on DrupalCI
    
    (...
larowlan’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 10.1.x and backported all the way to 9.4.x

  • larowlan committed d6ef1fa5 on 9.5.x
    Issue #3343495 by alexpott: Fix commit-code-check.sh on DrupalCI
    
    (...
drumm’s picture

(Updating to resolve Drupal.org issue indexing issue, please disregard.)

wim leers’s picture

wim leers’s picture

I can't believe @alexpott figured out the correct solution so quickly and @larowlan committed it … all after my late EOD yesterday, meaning that in my new workday, this problem is 100% gone 🤩🤯

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.