commitlint-github-action icon indicating copy to clipboard operation
commitlint-github-action copied to clipboard

Only check the HEAD commit of a PR

Open sonrohan opened this issue 2 years ago • 6 comments

Could we add a flag that only checks the head commit of the feature branch on PR?

If I have a branch like this

TICKET-123 Do some work
fix x
fix y
add unit test

I want this to only run on TICKET-123 Do some work

sonrohan avatar Mar 31 '22 19:03 sonrohan

I'm not quite sure, but I think you could already achieve that by setting fetch-depth: 1 in the checkout action, don't configure it as 1 is the default. The way this action works is by getting the git commit information from the local environment, so if you only fetch a single commit we'd run on just that (I think). Please let me know if that resolves your issue!

jdbruijn avatar Apr 01 '22 06:04 jdbruijn

Thanks for the quick response! Actually tried to change the fetch depth to 1 and also even tried 2, and it threw some errors. I'm on my phone right now so I don't have them, but I can update this comment later with the relevant error. It didn't seem to worth though is the tldr

sonrohan avatar Apr 01 '22 06:04 sonrohan

Ah yeah, I guess you're right. In the PR we'll get a commit SHA range from GitHub, so we'll try to run on that range. In the case fetch-depth: 1 however, not all commits we'd need are available and you get an error (see #340). Then this is a valid feature request and I'll leave it up to @wagoid to decide what to do with it 😉

jdbruijn avatar Apr 01 '22 06:04 jdbruijn

Thanks! If you need someone to contribute this to the codebase I'm happy to take a crack at it. Just let me know.

sonrohan avatar Apr 01 '22 06:04 sonrohan

Hey @sonrohan! That seems like a nice feature. @jdbruijn your comment made me wonder if we should support a similar fetch-depth param in the action? So if we pass fetch-depth: 1 to our action it would analyze only the HEAD commit in the end.

Thanks! If you need someone to contribute this to the codebase I'm happy to take a crack at it. Just let me know.

@sonrohan thanks! I would be happy to review it 💪

wagoid avatar Apr 06 '22 21:04 wagoid

Yeah I think we should name it commit-depth or something like that to avoid confusion with the checkout parameter.

jdbruijn avatar Apr 07 '22 09:04 jdbruijn

Folks, is this closed? I have a similar use case to only test against the latest commit.

Sakethtadimeti avatar Nov 15 '22 11:11 Sakethtadimeti

Hi @Sakethtadimeti, the issue is still open. I won't be able to work on it in the near future, but happy to review any PRs!

wagoid avatar Nov 17 '22 13:11 wagoid

@wagoid Please provide write access.

ERROR: Permission to wagoid/commitlint-github-action.git denied to Sakethtadimeti.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Sakethtadimeti avatar Nov 19 '22 18:11 Sakethtadimeti

@Sakethtadimeti you will need to create a fork of the repo, then submit a pull request.

wagoid avatar Nov 19 '22 19:11 wagoid

Hey @wagoid, please have a look at this PR https://github.com/wagoid/commitlint-github-action/pull/595. Many thanks for considering my request.

Sakethtadimeti avatar Nov 20 '22 08:11 Sakethtadimeti

the PR is merged, can the issue be closed?

SvenStaehs avatar Jul 19 '23 09:07 SvenStaehs

the PR is merged, can the issue be closed?

Sure 😃

Sakethtadimeti avatar Jul 24 '23 01:07 Sakethtadimeti