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

New getLastTag logic doesn't find my beta tags #48

Closed
adambalint-srg opened this issue Nov 4, 2022 · 9 comments
Closed

New getLastTag logic doesn't find my beta tags #48

adambalint-srg opened this issue Nov 4, 2022 · 9 comments
Labels
bug Something isn't working

Comments

@adambalint-srg
Copy link

The new logic which was implemented in #47 by @marcocesarato doesn't find previous beta tags. In my repository I have only alpha and beta versions now, like v2.0.0-beta.8. I don't have v2.0.0 now, because the code is not in this phase yet.
But the preg_grep fiters out every tag which contains -

$tagsFound = preg_grep('/^' . $prefixQuote . '[^-]*$/', $tagsArray);

Why this logic was implemented? I can't create v2.0.0-beta.9 version because of this logic.

@marcocesarato
Copy link
Owner

marcocesarato commented Nov 4, 2022

Hi, the new logics been implemented on #46, and on #47 been readapted to work with --merged flag.
You right, I see some missing logics on #46 that need to be adjusted on

public static function getLastBetaTag(string $lastTag = ''): ?string

and here
$extraRelease = Repository::getLastBetaTag($newVersion);

I'll work on it.

@adambalint-srg
Copy link
Author

Thanks, I can do it now with specifying from tag and new version manually, but I would be easier with the fixed logic :)

@marcocesarato marcocesarato added the bug Something isn't working label Nov 4, 2022
@marcocesarato
Copy link
Owner

Should be solved on 1.15.5, let me know if all works fine.

@adambalint-srg
Copy link
Author

@marcocesarato Sorry, I could check it now. I've updated to the lastest version, and the situation is the same.
I have this existing tag: v2.0.0-beta.10
I run the changelog generation with this command: vendor/bin/conventional-changelog --beta

It throws an error: fatal: ambiguous argument '0.0.0...HEAD': unknown revision or path not in the working tree.

It seems that it doesn't find the previous tag :/

@marcocesarato marcocesarato reopened this Nov 24, 2022
@adambalint-srg
Copy link
Author

@marcocesarato Maybe I can try to help with a PR tomorrow, or next week.

@marcocesarato
Copy link
Owner

marcocesarato commented Nov 24, 2022

@adambalint-srg I tried to replicate the error using the last version (v1.15.6).
I created a tag v1.0.0-beta.1 on a repository and executed conventional-changelog --beta, the result been v1.0.0-beta.2.
These tags were both on the same branch. I haven't tried it on various branches, but I don't believe it would be an issue.

Maybe I'm missing something else?

@marcocesarato Maybe I can try to help with a PR tomorrow, or next week.

Yes thanks, it would be greatly appreciated

@adambalint-srg
Copy link
Author

@marcocesarato Strange, I also tried it on the same branch, the result is the same, it tries to find the 0.0.0 version, because it doesn't find alpha/beta tags. I've tried with debug, and found this situation:

$tagsArray = explode(self::$delimiter . "\n", $tags);
$prefixQuote = preg_quote($prefix);
The $tagsArray contains every tags:

array (  
  0 => 'v2.0.0-beta.10',
  1 => 'v2.0.0-beta.9',
  ...
  23 => 'v2.0.0-alpha.0',
  28 => 'master',
  29 => 'hotfixes'
)

$tagsFound = preg_grep('/^' . $prefixQuote . '[^-]*$/', $tagsArray);
But in line 76 it filters this array, and find items which starts with v and doesn't contain -. With this all of our alpha/beta tags will be filtered out. And the $tagsFound array will be empty.
Why this filter is there?

I've tried it with a clean repo, and yes, the version number is updated in composer.json (packageBump is turned off in my other project), and the changlog contains the correct version, but the history of the changelog entry is empty, and the generated diff link is from the version 0.0.0 https://github.com/ownser/repository/compare/0.0.0...v2.0.0-beta.11

With debug the situation is the same, in getLastTag it doesn't find the first tag, and it throws an error in console output:

fatal: ambiguous argument '0.0.0...HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

I've opened a PR for this, I think removing the - condition from regex won't cause problems.

@marcocesarato
Copy link
Owner

I found the problem, was in another part of the code where it wasn't implemented well for some cases.
Released on 1.16.0. Let me know if now it works.

@adambalint-srg
Copy link
Author

@marcocesarato I can confirm that it's OK now! Thanks for the fix :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants