Skip to content

Commit

Permalink
New git ontology component with new GitTracked mixin
Browse files Browse the repository at this point in the history
This aims to be the foundation for data models of Git-tracked content.
The availability of a globally unique identifier in this context
allows for great flexibility in model specification. At the same time,
introducing a `identifier:true` property in a class hierarchy can be
problematic, because turning an existing base-class property into an
identifier in a derived class does not seem to be possible
(#30).

This approach uses a dedicated mixin class for this purpose.

The identifier itself uses the `meta_id` slot, and is intentionally
distinct from the `gitsha` property. The identifier is composed from
the `gitsha` by adding a corresponding namespace prefix. This keeps
the identifier property uniform across unrelated classes, while
also preserving the semantics of the identifier type.
  • Loading branch information
mih committed Jan 4, 2024
1 parent b94ef17 commit 691d3c3
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 28 deletions.
30 changes: 2 additions & 28 deletions src/linkml/git-provenance-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,14 @@ prefixes:
linkml: https://w3id.org/linkml/
prov: http://www.w3.org/ns/prov#
imports:
- git
- labeling
- meta_utils
- provenance
- types
default_prefix: dlco


slots:
gitsha:
description: >-
SHA1 identifier of a Git object.
range: SHA1


classes:
# TODO orthogonalize/consolidate with datalad-dataset:Commit
# the relevant class is not this one, but the
Expand All @@ -37,31 +31,11 @@ classes:
A revision or an individual change in a Git repository.
mixins:
- CommitProvenance
slots:
- gitsha
- meta_id
- GitTracked
slot_usage:
gitsha:
description: >-
SHA1 identifier of the commit object.
meta_id:
pattern: "^gitsha:[0-9a-f]{40}$"
description: >-
SHA1 identifier written as a CURIE in an explicit
`gitsha:` namespace.
unique_keys:
gitsha:
description: >-
A commit's GITSHA is a globally unique, content-based identifier
of that commit.
notes:
- The `gitsha` slot could have been labled to be the one identifier
of a Commit-type object. However, we use `meta_type` for
consistency and use its CURIE-format to assign an explicit
namespace.
unique_key_slots:
- gitsha
CommitProvenance:
mixin: true
Expand Down
41 changes: 41 additions & 0 deletions src/linkml/git.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
id: https://concepts.datalad.org/git
name: git
title: Git concepts
description: >
TODO
prefixes:
gitsha: https://concepts.datalad.org/namespace/gitsha/
dlco: https://concepts.datalad.org/ontology/
imports:
- meta_utils
- types
default_prefix: dlco


slots:
gitsha:
description: >-
SHA1 identifier of a Git object.
range: SHA1


classes:
GitTracked:
mixin: true
description: >-
Mixin class for any ressource tracked by Git, thereby having a unique
`gitsha` identifier.
slots:
- gitsha
- meta_id
slot_usage:
meta_id:
description: >-
SHA1 based identifier in the form of a CURIE with an explicit
`gitsha:` namespace prefix.
equals_expression: "gitsha:{gitsha}"
pattern: "^gitsha:[0-9a-f]{40}$"
comments:
- Because there can only be a single main `identifier`, this mixin
cannot be used on classes that already have or inherited another
property declared as `identifier:true`.

0 comments on commit 691d3c3

Please sign in to comment.