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

Ability to update the repository description #7376

Merged
merged 10 commits into from Aug 17, 2023

Conversation

adutra
Copy link
Contributor

@adutra adutra commented Aug 16, 2023

Note: the update repo functionality is implemented in the old model at adapter level, although, it seems unused. This PR brings the same functionality to the new model.

Copy link
Member

@dimas-b dimas-b left a comment

Choose a reason for hiding this comment

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

Changes LGTM, but it does not look like the new functionality can be accessed. Do you mean to have another PR to expose it somewhere?

@dimas-b
Copy link
Member

dimas-b commented Aug 16, 2023

Would it make sense to add a description update command to quarkus-cli?

@adutra
Copy link
Contributor Author

adutra commented Aug 16, 2023

Changes LGTM, but it does not look like the new functionality can be accessed. Do you mean to have another PR to expose it somewhere?

Exactly, the idea is to use this functionality in the importer, in order to "mark" the repository as fully imported. I have a draft already: #7380 .

@adutra
Copy link
Contributor Author

adutra commented Aug 16, 2023

Would it make sense to add a description update command to quarkus-cli?

At this point, that is not required as the only update to the repo description will happen internally inside the importer. We can always add that later though.

persist,
(p, retryState) -> {
try {
Reference reference = Objects.requireNonNull(persist.fetchReference(REF_REPO.name()));
Copy link
Member

Choose a reason for hiding this comment

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

We should probably fix the javadoc of REF_REPO, which currently says Internal reference with always exactly one commit ...

persist.storeObj(string);
b.addAdds(commitAdd(KEY_REPO_DESCRIPTION, 0, requireNonNull(string.id()), null, null));
b.addAdds(
commitAdd(KEY_REPO_DESCRIPTION, 0, requireNonNull(string.id()), null, UUID.randomUUID()));
Copy link
Member

Choose a reason for hiding this comment

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

This change will only work for new repositories, but existing repositories do not have a content-ID for the repo-description. The update-logic does not work without a content-ID.

I'd prefer to leave the content-ID as null. (There's no need for a CID here)

I know that the repo-config stuff uses a CID, see comment in SLImpl

existing = existingValueId != null ? fetchString(requireNonNull(existingValueId)) : null;
}
}
if (existingContentId == null) {
Copy link
Member

Choose a reason for hiding this comment

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

This makes updating repo-descriptions of already existing repos impossible (those have no CID for repo-description).

Mabe replacing the if with a simple else helps here.

Should also have some comment to explain the logic wrt repo-desc + repo-config

@Override
public RepositoryDescription updateRepositoryDescription(RepositoryDescription newDescription)
throws RetryTimeoutException {
// prevent modification of read-only attributes
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This came to my mind after @dimas-b suggestion to introduce an option in quarkus-cli to allow end users to modify the repo description. If we ever do that later, I think we'd need a safety net like this one.

.putProperties("updated", "true")
// read-only properties, should be ignored
.defaultBranchName("main2")
Copy link
Member

Choose a reason for hiding this comment

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

Heh, exactly this one might be updated. Let's remove "defaultBranchName" from that check.
I'm not sure whether there'll ever be a command to update arbitrary information - rather per attribute.

.putProperties("updated", "true")
// read-only properties, should be ignored
.defaultBranchName("main2")
.oldestPossibleCommitTime(Instant.ofEpochSecond(12345))
Copy link
Member

Choose a reason for hiding this comment

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

This and the below setting are actually read-only attributes.

@adutra adutra merged commit 9c293ca into projectnessie:main Aug 17, 2023
17 checks passed
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.

None yet

3 participants