codingame_tools.contribution_manager.contribution_commit_data¶
contribution_commit_data
¶
Remote commit metadata for the git repo backing data/ (see manager/git_repo)--split two
ways, both built from a CgContribution at the moment it's fetched/pushed:
-
CgContributionCommitMetadata: the handful of fast facts (contribution ID, version, cover binary ID/hash) needed often and cheaply--written as git trailers on everyserver-branch commit (seecodingame_tools.contribution_manager.layout'sTRAILER_*constants), so aserver-branch commit is self-describing without needing to look anywhere else. -
contribution-version-data.json(built viaredact_commit_contribution): the complete redactedCgContribution, committed onto theversion-dataorphan branch, one commit per server version--kept as a full snapshot rather than a narrower schema (deliberately, same rationale as before this was git-backed) so nothing here needs to change if some future need for another field shows up. Every field that's duplicated inCgContributionView/contribution-data.json--the diffable content living indata/--is redacted to an empty placeholder first, includingcover_binary_id(tracked instead as its ownCgContributionCommitMetadatafield/trailer).
CONTRIBUTION_COMMIT_DATA_FILE_NAME
module-attribute
¶
CONTRIBUTION_COMMIT_DATA_FILE_NAME = 'contribution-version-data.json'
Name of the single file committed onto the version-data branch (see
codingame_tools.contribution_manager.layout.VERSION_DATA_BRANCH_NAME) at each server version.
CgContributionCommitMetadata
dataclass
¶
CgContributionCommitMetadata(extra_data=dict(), contribution_id='', version=0, cover_binary_id=None, cover_binary_hash=None)
Bases: JSONWizardX
The four fast facts about a server-branch commit--built from a CgContribution at fetch/
push time, and the single canonical shape both directions of git trailer conversion
(layout.TRAILER_* keys) go through, so there's one definition instead of hand-rolling
trailer keys ad hoc at each call site.
contribution_id
class-attribute
instance-attribute
¶
contribution_id = ''
The opaque contribution ID (CgContribution.public_handle).
version
class-attribute
instance-attribute
¶
version = 0
The server version number--passed to updateContribution's idempotency check on the next
push().
cover_binary_id
class-attribute
instance-attribute
¶
cover_binary_id = None
The binary ID of the cover image as of this commit (None if it has none).
cover_binary_hash
class-attribute
instance-attribute
¶
cover_binary_hash = None
The SHA256 (hex) content hash of the cover image identified by cover_binary_id (None if
there is none)--the source of truth for cover-image identity against the local working
copy (see CgContribution.cover_binary_id for why the ID alone isn't enough there). Always
computed by the caller (from the actual cover bytes) alongside redact_commit_contribution,
not derivable from a CgContribution alone--so there's no from_contribution() convenience
constructor here; callers build this directly with all four fields at hand.
redact_commit_contribution
¶
redact_commit_contribution(contribution)
Return a copy of contribution with every field that's duplicated in
CgContributionView/contribution-data.json redacted to an empty placeholder--draft,
ready_for_moderation, contribution_type (top-level), and last_version.data (the full
content payload, including cover_binary_id--tracked separately as
CgContributionCommitMetadata.cover_binary_id instead)--plus last_version.statement_html,
which is never needed at all (purely derivative, see its own docstring).
Source code in codingame_tools/contribution_manager/contribution_commit_data.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |