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

2400: Avoid overwriting mbox archive #1696

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

zhaosongzs
Copy link
Member

@zhaosongzs zhaosongzs commented Nov 18, 2024

Sometimes, the ArchiveWorkItem fails to retrieve the current contents of an mbox file while processing a PR. When this happens, it will resend all emails. Erik pointed out that in GitLab, creating a new file uses a POST request, while updating an existing file uses PUT. Similarly, GitHub requires the current "SHA" to update a file.

The ArchiveWorkItem can determine whether it found existing content in the mbox archive and choose the right method accordingly. If it incorrectly fails to retrieve the existing content from GitLab or GitHub, it will attempt to create a new file. This attempt should fail, triggering a retry of the WorkItem, which would ideally succeed in retrieving the existing content.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace

Issue

  • SKARA-2400: Avoid overwriting mbox archive (Bug - P3)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/skara.git pull/1696/head:pull/1696
$ git checkout pull/1696

Update a local copy of the PR:
$ git checkout pull/1696
$ git pull https://git.openjdk.org/skara.git pull/1696/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1696

View PR using the GUI difftool:
$ git pr show -t 1696

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/skara/pull/1696.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 18, 2024

👋 Welcome back zsong! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Nov 18, 2024

@zhaosongzs This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

🔍 One or more changes in this pull request modifies files in areas of the source code that often require two reviewers. Please consider if this is the case for this pull request, and if so, await a second reviewer to approve this pull request before you integrate it.

🌎 Applicable reviewers for one or more changes in this pull request are spread across multiple different time zones. Please consider waiting with integrating this pull request until it has been out for review for at least 24 hours to give all reviewers a chance to review the pull request.

After integration, the commit message for the final commit will be:

2400: Avoid overwriting mbox archive

Reviewed-by: erikj

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been no new commits pushed to the master branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot changed the title SKARA-2400 2400: Avoid overwriting mbox archive Nov 18, 2024
@zhaosongzs zhaosongzs marked this pull request as ready for review November 18, 2024 21:57
@openjdk openjdk bot added the rfr label Nov 18, 2024
@mlbridge
Copy link

mlbridge bot commented Nov 18, 2024

Webrevs

@@ -108,7 +108,7 @@ PullRequest createPullRequest(HostedRepository target,
* @param authorName Name of author and committer for commit
* @param authorEmail Email of author and committer for commit
*/
void writeFileContents(String filename, String content, Branch branch, String message, String authorName, String authorEmail);
void writeFileContents(String filename, String content, Branch branch, String message, String authorName, String authorEmail, boolean createNewFile);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the javadoc with the new parameter and make it clear what should happen when set to true or false. If set to true, the call will fail if the file exists. If set to false, the call will fail if the file does not exist.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do

@@ -291,7 +291,7 @@ public Optional<String> fileContents(String filename, String ref) {
}

@Override
public void writeFileContents(String filename, String content, Branch branch, String message, String authorName, String authorEmail) {
public void writeFileContents(String filename, String content, Branch branch, String message, String authorName, String authorEmail, boolean createNewEmail) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable name doesn't make sense here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching it! I was in a hurry when working on it

@@ -229,7 +229,7 @@ public Optional<String> fileContents(String filename, String ref) {
}

@Override
public void writeFileContents(String filename, String content, Branch branch, String message, String authorName, String authorEmail) {
public void writeFileContents(String filename, String content, Branch branch, String message, String authorName, String authorEmail, boolean createNewFile) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implementation should also enforce the new behavior so we catch any mistakes in testing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix it

@zhaosongzs zhaosongzs marked this pull request as draft November 18, 2024 23:18
@openjdk openjdk bot removed the rfr label Nov 18, 2024
@zhaosongzs zhaosongzs marked this pull request as ready for review November 18, 2024 23:44
@openjdk openjdk bot added the rfr label Nov 18, 2024
@openjdk openjdk bot added the ready label Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants