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

auto version: Confusing behavior of Conventional Commits Plugin #1719

Closed
Yeti-or opened this issue Jan 14, 2021 · 5 comments · Fixed by #1723
Closed

auto version: Confusing behavior of Conventional Commits Plugin #1719

Yeti-or opened this issue Jan 14, 2021 · 5 comments · Fixed by #1723
Labels
bug Something isn't working released This issue/pull request has been released.

Comments

@Yeti-or
Copy link

Yeti-or commented Jan 14, 2021

Describe the bug

First of all we don't use labels on our PR, and use "conventional-commits", "npm" & "slack" plugins.
We have two problems with CC Plugin, and I believe they are connected.

Let's discuss master branch flow:

When you merge PR and don't label PR;
cc-plugin will omit merge commit from commits that participate in auto version:

// Omit the commit if one of the commits in the PR contains a CC message since it will already be counted
await Promise.all(
prCommits.map(async (c) => {
try {
const label = await getBump(c.commit.message);
if (label) {
shouldOmit = true;
}
} catch (error) {}
})
);
return shouldOmit;

so if you have something like these:

*   8d32016 Merge pull request #3 from yeti-or.test-3
|\
| * d7c4936  feat: new shinny feature
|/
*

Everything is okay, and auto version returns minor

For case when we have no need to release

*   8d32016 Merge pull request #3 from yeti-or.test-3
|\
| * d7c4936  build: some chore work
|/
*

auto version will return nothing.

But if we have two commits:

*   8d32016 Merge pull request #3 from yeti-or.test-3
|\
| * d7c4936  build: some chore work
| * dbc91a0  feat: new shinny feature
|/
*

I would expect to get minor but instead I get nothing from auto version
because auto version checks necessity of release in first commit. And first one was omited by cc-plugin.

const lastMergedCommitLabels = prLabels[0] || [];
const releaseLabels = labelMap.get("release") || [];
const skipRelease = onlyPublishWithReleaseLabel
? !lastMergedCommitLabels.some((label) => releaseLabels.includes(label))
: lastMergedCommitLabels.some((label) => skipReleaseLabels.includes(label));
if (skipRelease) {
return SEMVER.noVersion;
}

So whole pr with bunch of feat/major commits will be skipped.
And you couldn't predict these because canary version was published okay in your PR.

Second problem:

I suppose it's similar problem. If we write in pull-request summary something using conventional-commit msg:

Very useful PR: several features here

Title of pr will be provided to merge commit.

modifiedCommit.subject = info.data.title || modifiedCommit.subject;

Then CC-Plugin will try to determine version of these commit:

const label = await getBump(`${commit.subject}\n\n${commit.rawBody}`);

inside getBump CC- Plugin will parse PR title.

const conventionalCommit = parse(message);

conventionalCommit would be smth like this:

< {
<   type: 'Very useful PR',
<   scope: null,
<   subject: 'several features here',
<   merge: null,
<   header: 'several features here',
<   body: 'undefined',
<   footer: null,
<   notes: [],
<   references: [],
<   mentions: [],
<   revert: null
< }

so label would be 'skip'

And moreover this commit wouldn't be omitted, because it has label and cc-plugin omits only commits without labels:

commit.labels.length === 0

So you could skip release by using conventional commits in your pr title. But I didn't expected it, and docs didn't prepared me.

It could be done in such steps:

  • create pr from one chore commit
  • github suggest you to use commit message as PR title
  • add one more feat/fix commit after review
  • merge pr with two commits
  • don't get release (skipped because of PR title)

still get canary version in pr though

Expected behavior

  1. Expect auto to treat pr as a whole bunch of changes, and not to skip release because of first commit, but look at them all and skip only if all commits are skip-release
  2. Expect CC-Plugin not to use pr title as check for skipping release. At least don't skip on everything that has someword: text.

Environment information:

Environment Information:

"auto" version: v10.6.2
"git"  version: v2.29.1
"node" version: v12.16.1

Project Information:

✔ Repository:      ***
✔ Author Name:     Vasiliy Loginevskiy
✔ Author Email:    yeti.or@gmail.com
✖ Current Version: v
✔ Latest Release:  ***
✖ Labels configured on GitHub project (Try running "auto create-labels")

GitHub Token Information:

✔ Token:            [Token starting with ***]
✖ Repo Permission:  read
✔ User:             ***
✔ API:
✔ Enabled Scopes:   gist, notifications, repo, user, workflow, write:discussion, write:packages
✔ Rate Limit:       4997/5000
@Yeti-or Yeti-or added the bug Something isn't working label Jan 14, 2021
@hipstersmoothie
Copy link
Collaborator

hipstersmoothie commented Jan 14, 2021

This is a tricky one to fix!

Just to be clear you expect:

*   8d32016 Merge pull request #3 from yeti-or.test-3 (PR TItle: Enhancement PR)
|\
| * d7c4936  build: some chore work
| * dbc91a0  feat: new shinny feature
|/
*

to create a minor release and for the changelog to look something like

#### Enhancement

- Enhancement PR
- new shiny feature

####  Build

- some chore work

#### Authors: 1

- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))

@hipstersmoothie
Copy link
Collaborator

Expect auto to treat pr as a whole bunch of changes, and not to skip release because of first commit, but look at them all and skip only if all commits are skip-release

The above comments pertain to this and you can test out if I fixed it by installing the canary version from this PR.

Expect CC-Plugin not to use pr title as check for skipping release. At least don't skip on everything that has someword: text

This breaks with how auto has worked so far. We treat the PR title as a commit message. If that title has a conventional commit that isnt a patch, minor, major it defaults to skip. If you add a label to the PR though that will take precedence.

@aleclarson
Copy link
Contributor

It would be great if #1723 checked all commits after the latest version, instead of only the most recent commit.

@adierkens
Copy link
Collaborator

🚀 Issue was released in v10.23.0 🚀

@adierkens adierkens added the released This issue/pull request has been released. label Mar 26, 2021
@hipstersmoothie
Copy link
Collaborator

@Yeti-or if you find any remaining issue with the plugin feel free to open another issue. Thanks for the in depth bug report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released This issue/pull request has been released.
Projects
None yet
4 participants