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

Fix "There are uncommitted changes" error messages when using mastodon-git with maston (core) 1.0.0-SNAPSHOT-31 #23

Merged
merged 5 commits into from
Oct 1, 2024

Conversation

maarzt
Copy link
Collaborator

@maarzt maarzt commented Sep 25, 2024

While using mastodon-git with the latest mastodon 1.0.0-SNAPSHOT-31, a user would often get error messages: that the repository is not clean "There are uncommitted changes. Please add a save point before pulling":

grafik

The problem also causes the unit tests to fail when using the latest mastodon core dependency.

In version 1.0.0-SNAPSHOT-31 the way Mastodon saves its projects/datasets has been changed, and mastodon-git needs to adapt. If mastodon saves into a folder now the entire old folder is removed. Which resulted in files project.xml_remote and other files that where created by mastodon-git in the mastodon.project folder are always be removed. Git notices these missing files and reports that as a "repository is not clean" error.

The problem is solved by no longer storing the files "project.xml_remote" etc. in the "mastodon.project/" folder. They are now stored in separate folder "mastodon.remote_data/".

With this changes user should again be able to do all operations mastodon-git provides.

TODOs

  • delete all test repositories that still use the old "project.xml_remote" files to avoid confusing users
  • rename "mastodon.remote" to "mastodon.initial_state"
  • cut a release

The way Mastodon save its projects/datasets has been changed, and
mastodon-git needs to adapt. If mastodon save into a folder now the entire
old folder is removed. Which resulted in files "project.xml_remote" which
are used by the mastodon git implementation to always be removed.

The problem is solved by no longer storing these files in the
mastodon.project folder. They are now stored in a mastodon.remote_data
folder instead.
@maarzt maarzt self-assigned this Sep 25, 2024
Copy link
Collaborator

@stefanhahmann stefanhahmann left a comment

Choose a reason for hiding this comment

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

It is difficult to test, if this PR improves the user experience, since it is not described, how the error messages that the user receives can be reproduced. I was not able to test, if the intended changes work as expected.

In the javadoc, it is mentioned that the files gui.xml, project.xml and dataset.xml.backup are treated specially. It would be good if the reasoning of this special treatment is mentioned. Also, it is unclear, why the "*_remote" files are needed. Some short explanation in the source code would help.

When trying to download a Shared Project with this version of the code, I am getting this error message:

grafik

When trying to do the same with the 0.0.1 release of mastodon-git the same error message does not occur.

With both version 0.0.1 and 0.0.2-SNAPSHOT, I am getting this error message when trying to Download changes (i.e. pull), even though I have not made local changes before:

grafik


Path remoteFolder = directory.toPath().resolve( MASTODON_REMOTE_DATA_FOLDER );
if ( Files.exists( remoteFolder ) )
throw new MastodonGitException( "The repository already contains a shared mastodon project: " + repositoryURL );
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
throw new MastodonGitException( "The repository already contains a shared mastodon project: " + repositoryURL );
throw new MastodonGitException( "The specified directory already contains a shared mastodon project: " + repositoryURL + ". Please specify an empty directory.");

Copy link
Collaborator Author

@maarzt maarzt Oct 1, 2024

Choose a reason for hiding this comment

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

You misunderstood the code here. The user has to select an empty directory and an empty git repository in order to share a project. This message is shown if the repository is not empty. I will change the text to:

Suggested change
throw new MastodonGitException( "The repository already contains a shared mastodon project: " + repositoryURL );
throw new MastodonGitException( "The repository already contains a shared mastodon project: " + repositoryURL
+ "\nPlease specify an empty git repository." );

@@ -114,21 +117,26 @@ public static MastodonGitRepository shareProject(
.setCredentialsProvider( credentials.getSingleUseCredentialsProvider() )
.setDirectory( directory )
.call();
final Path mastodonProjectPath = directory.toPath().resolve( "mastodon.project" );
final Path mastodonProjectPath = directory.toPath().resolve( MASTODON_PROJECT_FOLDER );
if ( Files.exists( mastodonProjectPath ) )
throw new MastodonGitException( "The repository already contains a shared mastodon project: " + repositoryURL );
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
throw new MastodonGitException( "The repository already contains a shared mastodon project: " + repositoryURL );
throw new MastodonGitException( "The specified directory already contains a mastodon project: " + repositoryURL + ". Please specify an empty directory.");

The previous name was "mastodon.remote" which can be considered confusing.
A copy of that folder is in every locally cloned repository.

The new name reflects that fact that the files are copied to initialize a
working Mastodon project after cloning a repository.
Minor refactoring use try with resource. Extract a private method. Reduce
code duplication.
@maarzt maarzt force-pushed the fix-repository-not-clean-bug branch from cafb617 to 4905225 Compare October 1, 2024 13:32
This PR fixes a bug that only appears when linked with mastodon core
version 1.0.0-beta-31-SNAPSHOT. However the fixed mastodon-git works with
both beta-30 and the latest snapshot. Not having a snapshot release is
better for being able to cut a release.
@maarzt maarzt changed the title Fix "Repository not clean" error messages when using mastodon-git with maston (core) 1.0.0-SNAPSHOT-31 Fix "There are uncommitted changes" error messages when using mastodon-git with maston (core) 1.0.0-SNAPSHOT-31 Oct 1, 2024
@maarzt
Copy link
Collaborator Author

maarzt commented Oct 1, 2024

We did a successful functional test yesterday. And the error message "FileNotFoundException" were due to the usage of a outdated matodon-git data repository. This change is backwards compatible. But I think we don't need to be backwards compatible yet. I will delete all outdated repositories. And merge this PR.

@maarzt maarzt merged commit 89443a9 into master Oct 1, 2024
1 check passed
@maarzt maarzt deleted the fix-repository-not-clean-bug branch October 1, 2024 13:48
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