Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot destructure property hasChanges #209

Open
FabioRosado opened this issue Sep 14, 2020 · 4 comments
Open

Cannot destructure property hasChanges #209

FabioRosado opened this issue Sep 14, 2020 · 4 comments

Comments

@FabioRosado
Copy link

Hello,

Thank you for creating this action, I'm using github actions for the first time so I guess there is a lot I don't understand.

I'm trying to create an action that runs black linting to a python project.

This is my actions file

name: lint

on: 
  - push
  - pull_request

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-python@v2
      - uses: rocioar/gradual-black-formatter@v1
      - uses: gr2m/create-or-update-pull-request-action@v1.2.2
        env: 
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }

But when commit a change/open a PR, this action fails with:

Run gr2m/create-or-update-pull-request-action@v1.2.2
##[error]Cannot destructure property `hasChanges` of 'undefined' or 'null'.

Any idea what I am doing wrong or did I found a bug?

Thank you for you time.

@gr2m
Copy link
Owner

gr2m commented Sep 14, 2020

Hmm first time I see that error. It must be originating from this code

const { hasChanges } = await getLocalChanges(inputs.path);

The getLocalChanges method is here:

async function getLocalChanges(path) {
const output = await runShellCommand(`git status ${path || "*"}`);
if (/nothing to commit, working tree clean/i.test(output)) {
return {};
}
const hasUncommitedChanges = /(Changes to be committed|Changes not staged|Untracked files)/.test(
output
);
return {
hasUncommitedChanges,
hasChanges: hasUncommitedChanges
};
}

The result of await getLocalChanges(inputs.path) should always be an object ... 🤔

Can you share the full error stack please?

@FabioRosado
Copy link
Author

What would be the best way to do this? That error I've received from running the action so not sure how to do it sorry 😬

@gr2m
Copy link
Owner

gr2m commented Sep 14, 2020

Is your repository public?

The best way to help would be to create a new minimal repository, reproduce the steps to get to the state where the above error is thrown, document the steps so I can reproduce it myself. You could invite me to that repository too, then I can add some debugging steps myself

@FabioRosado
Copy link
Author

Hello,

thank you for the quick reply. I created a testing repo for github actions - GitHub action Test Repo

You can probably see the action that failed on the couple pushes and PR that I tried to raise. Hope this helps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants