User:TCipriani (WMF)/Gerrit/Tutorial/Materialize
Appearance
🧑🏽💻 Gerrit for Product Analytics–Tutorial
Materialize Changes
Now you can make changes to your repo. Here we'll follow along with the Creating a new schema tutorial from Wikitech.
# 1️⃣ Step 1
Change to your newly cloned schemas/event/secondary directory and run npm i to install all the software needed to make a new schema.
❇️ npm i
$ cd schemas/event/secondary $ npm i > schemas-event-secondary@1.0.0 postinstall > $(npm bin)/jsonschema-tools install-git-hook [2021-10-28 00:52:08.690 +0000]: Saving jsonschema-tools materialize-modified pre-commit hook to /home/user/src/schemas/event/secondary/.git/hooks/pre-commit added 249 packages, and audited 250 packages in 9s
Now you'll have a node_modules directory inside the schemas/event/secondary directory.
schemas/event/secondary/node_modules
├── acorn
├── acorn-jsx
├── ajv
├── ansi-colors
├── ansi-escapes
├── ansi-regex
├── ansi-styles
├── argparse
├── args
├── astral-regex
├── atomic-sleep
├── @babel
├── balanced-match
├── bluebird
├── brace-expansion
├── browser-stdout
├── call-me-maybe
├── callsites
├── camelcase
├── chalk
├── chardet
├── cli-cursor
├── cliui
├── cli-width
├── color-convert
├── color-name
├── compute-gcd
├── compute-lcm
├── concat-map
├── cross-spawn
├── dateformat
├── debug
├── decamelize
├── deep-is
├── define-properties
├── diff
├── doctrine
├── drange
├── emoji-regex
├── end-of-stream
├── es-abstract
├── escape-string-regexp
├── eslint
├── eslint-scope
├── eslint-utils
├── eslint-visitor-keys
├── espree
├── esprima
├── esquery
├── esrecurse
├── es-to-primitive
├── estraverse
├── esutils
├── external-editor
├── fast-deep-equal
├── fast-json-stable-stringify
├── fast-levenshtein
├── fast-redact
├── fast-safe-stringify
├── figures
├── file-entry-cache
├── find-up
├── flat
├── flat-cache
├── flatstr
├── flatted
├── format-util
├── fs-extra
├── fs.realpath
├── functional-red-black-tree
├── function-bind
├── get-caller-file
├── glob
├── globals
├── glob-parent
├── graceful-fs
├── growl
├── @hapi
├── has
├── has-flag
├── has-symbols
├── he
├── hosted-git-info
├── iconv-lite
├── ignore
├── import-fresh
├── imurmurhash
├── inflight
├── inherits
├── inquirer
├── is-buffer
├── is-callable
├── is-date-object
├── isexe
├── is-extglob
├── is-fullwidth-code-point
├── is-glob
├── is-regex
├── is-symbol
├── jmespath
├── joycon
├── jsonfile
├── jsonpath-plus
├── json-schema-compare
├── json-schema-faker
├── json-schema-merge-allof
├── json-schema-ref-parser
├── json-schema-traverse
├── json-stable-stringify-without-jsonify
├── js-tokens
├── js-yaml
├── leven
├── levn
├── locate-path
├── lodash
├── log-symbols
├── lru-cache
├── mimic-fn
├── minimatch
├── minimist
├── mkdirp
├── mocha
├── mri
├── ms
├── mute-stream
├── natural-compare
├── netmask
├── nice-try
├── node-environment-flags
├── node-fetch
├── object.assign
├── object.getownpropertydescriptors
├── object-inspect
├── object-keys
├── once
├── onetime
├── ono
├── optionator
├── os-tmpdir
├── parent-module
├── path-exists
├── path-is-absolute
├── path-key
├── pino
├── pino-pretty
├── pino-std-serializers
├── p-limit
├── p-locate
├── prelude-ls
├── progress
├── p-try
├── pump
├── punycode
├── quick-format-unescaped
├── randexp
├── readable-stream
├── recursive-readdir-sync
├── regexpp
├── require-directory
├── require-main-filename
├── resolve-from
├── restore-cursor
├── ret
├── rewire
├── rimraf
├── run-async
├── rxjs
├── safe-buffer
├── safer-buffer
├── semver
├── set-blocking
├── shebang-command
├── shebang-regex
├── signal-exit
├── slice-ansi
├── sonic-boom
├── split2
├── sprintf-js
├── string_decoder
├── string.prototype.trimend
├── string.prototype.trimleft
├── string.prototype.trimright
├── string.prototype.trimstart
├── string-width
├── strip-ansi
├── strip-json-comments
├── supports-color
├── table
├── text-table
├── through
├── tmp
├── tslib
├── type-check
├── type-fest
├── universalify
├── uri-js
├── util-deprecate
├── v8-compile-cache
├── validate.io-array
├── validate.io-function
├── validate.io-integer
├── validate.io-integer-array
├── validate.io-number
├── which
├── which-module
├── wide-align
├── @wikimedia
├── word-wrap
├── wrap-ansi
├── wrappy
├── write
├── y18n
├── yallist
├── yargs
├── yargs-parser
└── yargs-unparser
216 directories, 0 files
# 2️⃣ Step 2
Make a new directory for your schema lineage:
Create a new schema
$ mkdir -p jsonschema/mediawiki/desktop/button/click
And then add a current.yaml file in the directory jsonschema/mediawiki/desktop/button/click with your schema.
# 3️⃣ Step 3
Commit your change using git commit.
Below I run three commands:
git status– shows what files git knows about and whether those files have changed since git last saw themgit add– tells git that you'd like to include these files in your next commitgit commit– tells git that you're done working on the file. Adding-m "some message"will add a commit message to the code. Commit messages should use present tense (e.g., "Add" instead of "Added" or "Adding") and be less than 72 characters by convention.
✅ Git commit
$ git status
On branch master
Your branch is up to date with 'origin/master'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
jsonschema/mediawiki/
nothing added to commit but untracked files present (use "git add" to track)
$ git add jsonschema/mediawiki/
$ git commit -m 'Add mediawiki/desktop/button/click'
[2021-10-28 13:17:37.619 +0000]: Looking for modified current.yaml schema files in ./jsonschema/
[2021-10-28 13:17:37.668 +0000]: Materializing /home/thcipriani/Projects/gerrit-for-product-analytics/schemas/event/secondary/jsonschema/mediawiki/desktop/button/click/current.yaml...
[2021-10-28 13:17:37.678 +0000]: Dereferencing schema with $id /mediawiki/desktop/button/click/1.0.0 using schema base URIs ./jsonschema/,https://schema.wikimedia.org/repositories/primary/jsonschema/
[2021-10-28 13:17:37.703 +0000]: Materialized schema at /home/thcipriani/Projects/gerrit-for-product-analytics/schemas/event/secondary/jsonschema/mediawiki/desktop/button/click/1.0.0.yaml.
[2021-10-28 13:17:37.704 +0000]: Materialized schema at /home/thcipriani/Projects/gerrit-for-product-analytics/schemas/event/secondary/jsonschema/mediawiki/desktop/button/click/1.0.0.json.
[2021-10-28 13:17:37.704 +0000]: Created latest symlink /home/thcipriani/Projects/gerrit-for-product-analytics/schemas/event/secondary/jsonschema/mediawiki/desktop/button/click/latest.yaml -> 1.0.0.yaml.
[2021-10-28 13:17:37.705 +0000]: Created latest symlink /home/thcipriani/Projects/gerrit-for-product-analytics/schemas/event/secondary/jsonschema/mediawiki/desktop/button/click/latest.json -> 1.0.0.json.
[2021-10-28 13:17:37.705 +0000]: Created extensionless symlink /home/thcipriani/Projects/gerrit-for-product-analytics/schemas/event/secondary/jsonschema/mediawiki/desktop/button/click/1.0.0 -> 1.0.0.yaml.
[2021-10-28 13:17:37.706 +0000]: Created latest symlink /home/thcipriani/Projects/gerrit-for-product-analytics/schemas/event/secondary/jsonschema/mediawiki/desktop/button/click/latest -> 1.0.0.yaml.
[2021-10-28 13:17:37.706 +0000]: New schema files have been materialized. Adding them to git: /home/thcipriani/Projects/gerrit-for-product-analytics/schemas/event/secondary/jsonschema/mediawiki/desktop/button/click/1.0.0.yaml,/home/thcipriani/Projects/gerrit-for-product-analytics/schemas/event/secondary/jsonschema/mediawiki/desktop/button/click/latest.yaml,/home/thcipriani/Projects/gerrit-for-product-analytics/schemas/event/secondary/jsonschema/mediawiki/desktop/button/click/1.0.0,/home/thcipriani/Projects/gerrit-for-product-analytics/schemas/event/secondary/jsonschema/mediawiki/desktop/button/click/latest,/home/thcipriani/Projects/gerrit-for-product-analytics/schemas/event/secondary/jsonschema/mediawiki/desktop/button/click/1.0.0.json,/home/thcipriani/Projects/gerrit-for-product-analytics/schemas/event/secondary/jsonschema/mediawiki/desktop/button/click/latest.json
[master 46e19bc] Add mediawiki/desktop/button/click
7 files changed, 132 insertions(+)
create mode 120000 jsonschema/mediawiki/desktop/button/click/1.0.0
create mode 100644 jsonschema/mediawiki/desktop/button/click/1.0.0.json
create mode 100644 jsonschema/mediawiki/desktop/button/click/1.0.0.yaml
create mode 100644 jsonschema/mediawiki/desktop/button/click/current.yaml
create mode 120000 jsonschema/mediawiki/desktop/button/click/latest
create mode 120000 jsonschema/mediawiki/desktop/button/click/latest.json
create mode 120000 jsonschema/mediawiki/desktop/button/click/latest.yaml
You'll notice that a lot of things happened after you typed git commit. Git used a script to create version files for your new schema lineage. You can see them in your directory tree:
jsonschema/mediawiki/desktop/button/click/
├── 1.0.0 -> 1.0.0.yaml
├── 1.0.0.json
├── 1.0.0.yaml
├── current.yaml
├── latest -> 1.0.0.yaml
├── latest.json -> 1.0.0.json
└── latest.yaml -> 1.0.0.yaml