Skip to content

Conversation

@Usaldudo
Copy link
Contributor

The function increment(string, amount) has been refined to update only the last number in the provided string, simplifying its behaviour. Key changes include:

  1. Single Number Increment: The function now focuses on incrementing only the last number in the given string.

Example Usage

increment("1.2.3", 5); // Output: "1.2.8"

These changes aim to streamline the increment function for scenarios where updating only the last number is desired. Please review and merge as needed.

@kroese kroese merged commit e86c58b into action-pack:master Dec 14, 2023
@kroese
Copy link
Collaborator

kroese commented Dec 14, 2023

Thank you very much! I created a new release (v2.09) with this change included.

@kroese
Copy link
Collaborator

kroese commented Jan 4, 2024

@Usaldudo I noticed this new function doesn't work with negative numbers. For example if you increment -3 by 1, it returns -4 instead of -2. This worked correctly using the old function.

I guess the reason is that it doesnt take into account any - sign when searching for the last number. So maybe you can fix this if you have the time.

@Usaldudo Usaldudo deleted the update branch January 8, 2024 08:18
@Usaldudo Usaldudo restored the update branch January 8, 2024 08:20
@Usaldudo
Copy link
Contributor Author

Usaldudo commented May 31, 2024

Hi,
Thank you for your message. I appreciate your concern about the updates to the code. I've reviewed the commits: b7d20a1 (the old commit) and 2b3b258 (my commit).
After thoroughly checking both commits and conducting tests using the increment("-3", 1); function call, I can confirm that the result is indeed "-4" in both cases. This suggests that the behaviour remains consistent between the old and new versions of the code.
I've run tests in a GitHub Action. Here are the log links for comparison:
Latest version:
Latest Version Logs
Old version (v2.08):
Old Version Logs

@kroese
Copy link
Collaborator

kroese commented May 31, 2024

@Usaldudo Hi, thanks for your response! I cannot view your logs, because I get a AuthenticationFailed message. But I also did a test in this Action to show the problem:

https://github.com/action-pack/increment/actions/runs/9314390357/job/25638479963

When the value is -4, and you increment by 1 it should be -3 like in the previous version. But in your code the result is -5 instead:

Succesfully incremented TEST from -4 to -5.

Then when you increment that -5 result by -2 the result should be -7 but in your version the result is -3:

Succesfully decremented TEST from -5 to -3.

Maybe I am doing something wrong or overlooking something?

EDIT: It seems that this wrong behaviour also happens with the old code. I was sure that it worked correctly in the past, thats why I thought it was caused by your modification. But now it seems it never worked correctly, sorry.

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

Successfully merging this pull request may close these issues.

2 participants