Skip to content

Conversation

@Jamie-SA
Copy link
Contributor

@Jamie-SA Jamie-SA commented Oct 23, 2025

Closes #898
This PR prevents commits if an ontology file has a default prefix declared.
Everyone will need to run setup.cmd again.

Copy link
Contributor

@stevenchalem stevenchalem left a comment

Choose a reason for hiding this comment

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

I have tested this on Windows and it all looks good. I like the changes you made.

Copy link
Contributor

@stevenchalem stevenchalem left a comment

Choose a reason for hiding this comment

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

This needs a release note.

@Jamie-SA Jamie-SA marked this pull request as draft October 24, 2025 21:00
@Jamie-SA
Copy link
Contributor Author

I think I have got this back to what it was originally with Rebecca's release note update.

@Jamie-SA Jamie-SA marked this pull request as ready for review October 24, 2025 21:22
Copy link
Contributor

@stevenchalem stevenchalem left a comment

Choose a reason for hiding this comment

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

Tested successfully under Windows 11.

@Jamie-SA
Copy link
Contributor Author

@rjyounes why is it again that we set "git config core.filemode false" on this repo? It seems like the wrong option, I think the repo should track executable flags (even if Windows doesn't care). I keep having to set setup.cmd to executable every time I change branches (or every time I change branches that change that file).

@rjyounes
Copy link
Collaborator

@Jamie-SA Regarding the question about git config core.filemode false: I have a dim memory that it fixed something on Mac but I agree that it should be removed.

@@ -0,0 +1,4 @@
### Patch Updates

- Added a test in the git pre-commit hook to check for default PREFIX declarations in ontology files and cause the commit to fail if it finds one. For this to work, the setup.cmd command needs to be re-run to update the git hook. Issue [#898](https://github.com/semanticarts/gist/issues/898).
Copy link
Collaborator

@rjyounes rjyounes Oct 26, 2025

Choose a reason for hiding this comment

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

Why don't we have the pre-commit hook remove the prefix declaration, in the same way that the serializer reformats and makes some modifications?

Copy link
Collaborator

@rjyounes rjyounes Oct 26, 2025

Choose a reason for hiding this comment

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

One more issue: the pre-commit hook issues an error and blocks the commit when I have a file either in the ontologies directory or the root directory that is not being committed. It should be looking only at the files being committed, like the serializer.

This is another reason not to include the base directory (comment below), but that will not fully address it, since such a file could exist in my ontologies directory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mainly because it was faster/easier to just block the commit and I was trying to get this done so the release could get done.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Understood. That's why I want to postpone this to the next release when we can take the time to do it right. There's no need for it to go into 14.0.0.


# Get root directory of this git repository
base_dir=$(git rev-parse --show-toplevel)
# For repositories that have their ontology files in the project root directory
Copy link
Collaborator

Choose a reason for hiding this comment

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

I understand that you want to make this general, but since in this repository the ontologies are stored in the ontologies subdirectory, I don't think we should include this. Furthermore, other configurations are possible - e.g., for one client, we had models/ontologies. The point being it's not going to be all-purpose, and users are possibly going to have to modify the path if they copy this to another repo.

@@ -0,0 +1,18 @@
#!/usr/bin/env sh

# This file should be copied into the .git/hooks directory of the project.
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
# This file should be copied into the .git/hooks directory of the project.
# This file should be copied into the .git/hooks directory of the project. This is done automatically by running setup.cmd.

print("ERROR: there is a default PREFIX statement in file: ", filePath)
print("It must be removed from the file before you can commit your other changes.")
changed = True
# The following line would fix the file, then you would need to "git add filename"
Copy link
Collaborator

Choose a reason for hiding this comment

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

The serializer modifies files without having to re-add them.

@rjyounes
Copy link
Collaborator

Moved to next release. We need to get the right behavior before merging to develop.

@rjyounes
Copy link
Collaborator

We should also break these two functions up into two different PRs:

@Jamie-SA
Copy link
Contributor Author

I had them as two separate PRs, you merged them.

@rjyounes
Copy link
Collaborator

rjyounes commented Oct 28, 2025

Yes, that was a mistake. But one targeted the other so I thought you intended to merge them.

@rjyounes rjyounes marked this pull request as draft October 28, 2025 19:45
@Jamie-SA
Copy link
Contributor Author

Yes, that was a mistake. But one targeted the other so I thought you intended to merge them.

Since they modify the same files, it made since to me to stack them. Submitting them separately without one stacked on the other may result in merge conflicts.

Is there a preference in which one to focus on first?

@rjyounes
Copy link
Collaborator

Ensuring the user has the right pre-commit hook is more important than removing the default prefix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Automate removal of default prefix from ontology files

4 participants