Fixed retry and duplicated replacements
For good amount of time our scala-steward jobs are failing. Following changes fixed in our case, so creating the PR, might be useful port the changes to the main repo.
I hope this PR address the issue https://github.com/scala-steward-org/scala-steward/issues/2934
New Retry logic
- If
Retry-Afterheader present, then use the header value to retry (this was there before) - otherwise retry request after time specified by
X-Ratelimit-Resetheader. Header value is UTC epoch seconds. Here I took some assumptions- if the difference between header value and current UTC epoch seconds is more than 60 seconds then I retry after
60 seconds. That means max wait time would be60 seconds. - if the difference is negative then I retry after 1 second. That means min wait time is
1 second
- if the difference between header value and current UTC epoch seconds is more than 60 seconds then I retry after
- if neither of the headers present, wait
1.second
Here is the github suggested best-practices

~~Another issue~~
~~If there are duplicated replacements then the job was failing with StringIndexOutOfBoundsException. Added unit test to verify the behaviour~~.
Another issue
This deserves its own PR. I would also prefer to have a test for that in RewriteTest instead of in EditAlgTest.
Another PR crated to address the other issue https://github.com/scala-steward-org/scala-steward/pull/3016
Are you going to merge this PR?
In order to make this PR mergeable, you must resolve the conflicts first.