Changing the flow of updating teamwork omegat.project (Successor of #122)
This patch changes the flow of updating local teamwork "omegat.project" file with the content of remote copy of "omegat.project" on the git server.
Before this patch, the content of remote copy overwrites the local copy first, and then if the content lacks the git setting, it was added and then the "omegat.project" was updated to reflect the addition.
However, if OmegaT terminated early, such update may not happen and thus rendering the teamwork without proper git setting. When the remote copy of "omegat.project" lacks git setting, on the next opening, the project may no longer be a teamwork project (!). This confuses the end users to no end.
Pull request type
Please check the type of change your PR introduces:
- [x] Bug fix
- [x] Feature
- [ ] Documentation
- [ ] Build and release changes
- [ ] Other (describe below)
Which ticket is resolved?
- Link:
- Title:
What does this PR change?
This patch changes the workflow of update as follows.
-
Content of the remote copy of "omegat.project" on the server is written to local file, "omegat.project.NEW".
-
The content of this file is parsed.
-
If git-setting is missing in the content, it is added from then current setting from the local copy of "omegat.project". In this case, rewriting from the content of the remote copy does not happen.
-
Only if the remote copy is good enough to replace the current local copy, then we create a backup copy of the old "omegat.project" in "omegat.project.TIMESTAMP.bak". Then we RENAME "omegat.project.NEW" to "omegat.project".
With this flow, there is always a working copy of omegat.project on the local computer even if OmegaT terminates early. So we don't end up with incorrect non-teamwork copy even if the remote copy of "omegat.project" lacks git setting.
Also, this patch displays a warning dialog to warn the user when the remote copy of omegat.project on the git server lacks git setting. This should help end users to detect the wrong configuration early on.
Other information
This PR is successor of PR #122 which has not been no response from original author.
Integration test passed with 10 min. duration against git+ssh server.
I run an integration test with #211 configuration.
OmegaT respect repository URL specified when first download, and override remote omegat.project mapping for root.
@zephyrus00jp could you see and test it?
PR #220 improve integration test to handle a case that this PR try to solve, that is mapping configuration in team project. I've also update #211 an integration helper handle a mapping.
On 2022/03/29 14:49, Hiroshi Miura wrote:
@zephyrus00jp https://github.com/zephyrus00jp could you see and test it?
— Reply to this email directly, view it on GitHub https://github.com/omegat-org/omegat/pull/210#issuecomment-1081430465, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUNALELORFHT6AQ3NCI45LVCKKYLANCNFSM5PL6ZFVA. You are receiving this because you were mentioned.Message ID: @.***>
Sorry, I have had a hardware issue for about a month which has finally been solved since last week, and I am trying to catch up with backlog. I will try to look into the suggested change, etc. this week. (Except that I am afraid that I caught cold due to cold days over the weekend ...)
Chiaki
Thanks @zephyrus00jp to take a look at here. IMHO, there is still a space to be able to improved;
- There are comments that express "how", but it should explain a policy "what and why".
- There is not enough to test the code we changed. I think Pull-Request #220 will help for it.
Re-based on master again. Now you can test a repository mapping behavior with integration-test.
Integration test is passed for duration 40min.
@zephyrus00jp any comment?
@zephyrus00jp ping
When use the proposed change on new created fresh project, it show annoying warning dialog that say "Remote project file lacks git setting. This may be intentional, but likely an oversight." which is TF_REMOTE_PROJECT_LACKS_GIT_SETTING
org/omegat/gui/main/ProjectUICommands.java:508
if (props.getRepositories() == null) {
Log.logWarningRB("TF_REMOTE_PROJECT_LACKS_GIT_SETTING");
Core.getMainWindow().displayWarningRB("TF_REMOTE_PROJECT_LACKS_GIT_SETTING");
props.setRepositories(repos); // restore the mapping we just lost
needToSaveProperties = true;
} else {
That is added by commit "Changing the flow of updating teamwork omegat.project"( 9ff850e25571dd341c64d390591fe51eac9f ) where the previous is
if (props.getRepositories() == null) { // We have a project without mappings
props.setRepositories(repos); // so we restore the mapping we just lost
needToSaveProperties = true;
}
@zephyrus00jp Why we need to show dialog here?
merged as fad99d88d7ece47fc78a1ef27899492fe2778315