Skip to content

<git-show>

Render one commit's metadata and patch from a public GitHub, GitLab.com, or Bitbucket Cloud repository. See supported Git hosts for accepted repository URL formats and API limits.

Commit and patch

revision accepts a branch, tag, or full commit ID. Like git show <revision>, a branch or tag resolves to the commit it currently names.

html
<git-show
  repository="https://github.com/erkde/git-elements.js"
  revision="v0.1.1"
  line-numbers
></git-show>
Loading commit…The commit is unavailable.

Change summaries

Stat

Add stat for a per-file change graph and a totals line:

html
<git-show
  repository="https://github.com/erkde/git-elements.js"
  revision="v0.1.1"
  stat
></git-show>
Loading commit…The commit is unavailable.

The bars and counts come from the loaded commit patch. New, deleted, renamed, copied, and mode-changed files get compact labels. If several summary attributes are present, stat takes precedence.

Numstat

Add numstat to show additions and deletions for each file in the commit patch:

html
<git-show
  repository="https://github.com/erkde/git-elements.js"
  revision="v0.1.1"
  numstat
></git-show>
Loading commit…The commit is unavailable.

The counts come from the same patch as the full view. Binary files show - for both counts. If numstat and shortstat are both present, numstat is shown.

Short stat

Add shortstat to show changed-file, insertion, and deletion totals in place of the commit patch:

html
<git-show
  repository="https://github.com/erkde/git-elements.js"
  revision="v0.1.1"
  shortstat
></git-show>
Loading commit…The commit is unavailable.

The totals are calculated from the commit patch loaded by the nested <git-diff> element.

Revision semantics

<git-show> accepts one revision rather than a revision set. Two-dot and three-dot expressions belong to <git-log> and are rejected here.

For ordinary commits, the patch shows the commit relative to its first parent. Root commits are shown relative to an empty tree. See large-diff limits for commits whose host omits part of a patch.

The current implementation supports hosted public repositories only. It does not interpret local-only names such as HEAD, origin/main, reflog expressions, or unpushed commits.

Repository caching

An uncached show requires commit metadata and diff data from the provider. Identical instances share both requests. See repository caching for stored results, expiration, and reload() behavior.

API

Attributes

NameTypeDescription
repositorystringPublic repository URL.
revisionstringBranch, tag, or full commit ID to show.
line-numbersbooleanShow old and new line-number gutters in the patch.
shortstatbooleanShow file, insertion, and deletion totals instead of the patch.
numstatbooleanShow additions and deletions per file instead of the patch.
statbooleanShow a per-file change graph and totals instead of the patch.
theme"light" | "dark"Override the operating-system color preference.

Properties

NameTypeDescription
repositorystringPublic repository URL containing the revision.
revisionstringBranch, tag, or full commit ID currently selected.
lineNumbersbooleanWhether old and new line-number gutters are shown in the patch.
shortStatbooleanWhether file, insertion, and deletion totals replace the patch.
numStatbooleanWhether per-file addition and deletion counts replace the patch.
statbooleanWhether per-file change graphs and totals replace the patch.
commitGitShowCommit | nullNormalized metadata for the commit currently displayed. Read-only.
patchstringRaw unified diff text for the commit currently displayed. Read-only.

Methods

NameReturnsDescription
reload()Promise<void>Bypass cached data and request the commit and patch again.

Slots

NameDescription
loadingContent shown when loading exceeds the configured delay.
errorContent shown when the commit cannot be loaded.

Events

NameTypeDescription
loadEventFired after the commit and patch load and render.
errorEventFired when the commit or patch cannot be loaded.

CSS custom properties

NameDefaultDescription
--git-show-bg#f5f5f4Component background color.
--git-show-text-color#292524Primary text color.
--git-show-border-color#d6d3d1Border color.
--git-show-muted-color#78716cCommit label color.
--git-show-link-color#006d8fCommit hash link color.
--git-show-font-familyui-monospace, monospaceComponent font family.
--git-show-font-size12pxComponent font size.
--git-show-line-height20pxComponent line height.
--git-show-loading-delay150msDelay before slotted loading content appears.

CSS parts

NameDescription
containerContainer for the commit metadata and patch.
headerCommit metadata header.
hashFull commit hash and link.
authorCommit author identity.
dateAuthor date.
messageFull commit message.
subjectFirst line of the commit message.
bodyRemaining commit message body.
diffNested <git-diff> element.
loadingLoading-state container.
errorError-state container.

Exports and registration

NameKindModule
<git-show>Custom element registration@erkde/git-elements
GitShowElementClass@erkde/git-elements/components/git-show

See loading and errors for states and events, and styling for custom properties and CSS parts.

Released under the Apache-2.0 License.