Skip to content

Conversation

@Maxim-Durand
Copy link

@Maxim-Durand Maxim-Durand commented Apr 6, 2024

What Changed

Modified packages/core/src/git.ts so that getGitLog returns a list of commit object with the modified files path resolved from the root of the git repository instead of the execution directory.

Why

Commits objects were built with

files: (commit.files || []).map((file) => path.resolve(file)),

But the documentation of path.resolve states:

If, after processing all given path segments, an absolute path has not yet been generated, the current working directory is used.

Since it was only passing the file path returned by git log (which is a relative path) there was no absolute path generated and it would hence append the current directory (i.e the directory from where auto is run from) as a prefix to what git log returned. Meaning this would produce the correct absolute path only if auto is run from the root of the repository.

Todo:

  • Add tests
  • Add docs

Change Type

Indicate the type of change your pull request is:

  • documentation
  • patch
  • minor
  • major
@Maxim-Durand Maxim-Durand changed the title Auto appending commit file path from repo root instead of execution dir Apr 6, 2024
@hipstersmoothie hipstersmoothie added the patch Increment the patch version when merged label Apr 10, 2024
@Maxim-Durand
Copy link
Author

@hipstersmoothie Can you restart the CI ?

@Maxim-Durand
Copy link
Author

The CI failures seem unrelated to my code changes but not sure. @hipstersmoothie Should I investigate more or is this a known issue ?

@Maxim-Durand
Copy link
Author

@hipstersmoothie I'm really sorry for the spam but I'm also really eager to see this bug fix released so I'm able to use auto with https://github.com/restfulhead/npm-auto-plugins/tree/main/packages/filter-by-workspace-path

Considering the very small change involved in this PR and the fact CI pipelines seem broken, would you consider accepting the risk of merging without a green CI to release this bug fix sooner rather than later ?

On a different note, what is the process to add/reference a new plugin ? Does it have to be hosted in the plugins folder or can I just make a PR to change the readme and reference https://github.com/restfulhead/npm-auto-plugins/tree/main/packages/filter-by-workspace-path ?

@hipstersmoothie
Copy link
Collaborator

@Maxim-Durand maybe it's the node version in the actions that's causing the tests to fail? we need those passing before a merge

@Maxim-Durand
Copy link
Author

@Maxim-Durand maybe it's the node version in the actions that's causing the tests to fail? we need those passing before a merge

@hipstersmoothie Sorry for the long wait before an answer, I updated my fork with the latest code and tried running the tests locally but it fails on what feels unrelated errors to my changes:

Test Suites: 9 failed, 59 passed, 68 total
Tests:       65 failed, 785 passed, 850 total

With these error logs

yarn run v1.22.22
$ jest --runInBand
✖  error     No GitHub was found. Make sure it is available on process.env.GH_TOKEN.
✖  error     No GitHub was found. Make sure it is available on process.env.GH_TOKEN.
✖  error     No GitHub was found. Make sure it is available on process.env.GH_TOKEN.
⚠  warning   protected-branch: No "PROTECTED_BRANCH_REVIEWER_TOKEN" found in environment
⚠  warning   protected-branch: No "PROTECTED_BRANCH_REVIEWER_TOKEN" found in environment
⚠  warning   Cannot find module '/snapshot/auto/plugins/baz/dist/index.js' from 'scripts/jest-setup.js'
⚠  warning   Cannot find module 'auto-plugin-baz' from 'scripts/jest-setup.js'
⚠  warning   Cannot find module 'foobar' from 'scripts/jest-setup.js'
⚠  warning   Cannot find module './__tests__/test' from 'scripts/jest-setup.js'

Are there specific instruction to setup the testing suites ? Otherwise it looks like it's made to run on the CI only and I don't have access to it :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch Increment the patch version when merged

2 participants