Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ With [just](https://github.com/casey/just) installed, `just` lists the same task

`npm test` is the primary feedback loop: it drives the compiled binary against throwaway git repositories (a bare `origin` plus a working clone), exercising real `git fetch`/`merge`/`push` behavior end-to-end. `scripts/run-tests.mjs` hands node's runner explicit paths rather than a glob, so a pattern that stops matching fails loudly instead of reporting a green suite that ran nothing.

CI runs the suite on Linux and Windows across Node 22, 24, and 26 — both active LTS lines plus Current. Windows is in the matrix because git-fi behaves differently where the platform has no POSIX file modes: it stores the token without setting or checking `0600` (`AUTH-04`), and `--update` has to reach npm through the shell there (`UPDATE-05`).
CI runs the suite on Linux and Windows across Node 22, 24, and 26 — both active LTS lines plus Current. Windows is in the matrix because git-fi behaves differently where the platform has no POSIX file modes: it stores the token without setting or checking `0600` (`AUTH-04`), and `--update` has to reach npm or pnpm through the shell there (`UPDATE-05`).

When something is slow, `--debug` traces every git command with its elapsed time (`OPTION-11`) — which is how the fetch's `--no-tags` came about (`PRE-04`). How much that flag saves depends on the server, so measure with `--debug` in the repository in question rather than assuming.

Expand All @@ -53,7 +53,7 @@ npm run trial:off # unlink, restore the version it replaced

If `git fi` runs something other than what you expect, `which -a git-fi` lists every `git-fi` on your `PATH` in resolution order.

The published package — `npm install -g @gettyimages/git-fi`, documented on the [docs site](https://gettyimages.github.io/git-fi/#/quickstart) — is the official install for end users. Reach for it here mainly to test the distribution itself; local development runs from source.
The published package, installed as the [docs site](https://gettyimages.github.io/git-fi/#/quickstart?id=install) describes, is the official install for end users. Reach for it here mainly to test the distribution itself; local development runs from source.

## Project Structure

Expand Down
4 changes: 2 additions & 2 deletions SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ Install Integrity

`git fi` runs whichever `git-fi` comes first on `PATH`, so an installation can be complete and still never run. The state is silent from both ends: npm reports success, and the copy that would notice is the one not being reached.

- `INSTALL-01` Where the `git-fi` that `PATH` resolves first is not the copy executing, `--version` shall report it on stderr: the launcher `git fi` reaches, the copy answering, and how to resolve the two (delete the launcher, or move npm's prefix earlier on `PATH`). Reaching the running copy some other way — `npx`, an absolute path — is the state in which the report can be made at all, and asking which git-fi is installed is the moment it answers a question already being asked. It shall not print on any other command: a second installation is not itself a fault, and a line on every run would be noise to whoever has a reason for it. stdout shall carry only the version string, so anything parsing it is unaffected. `GIT_FI_NO_HINTS` shall suppress it; the update notice's other suppressions (`UPDATE-03`) shall not, since a pipeline reporting which binary it ran is the case this exists for. An unreadable `PATH` entry, an unresolvable entry point, or no `git-fi` on `PATH` at all shall leave the command silent rather than failing it.
- `INSTALL-01` Where the `git-fi` that `PATH` resolves first is not the copy executing, `--version` shall report it on stderr: the launcher `git fi` reaches, the copy answering, and how to resolve the two (delete the launcher, or move the bin directory of the package manager that installed this copy — npm's or pnpm's — earlier on `PATH`). Reaching the running copy some other way — `npx`, an absolute path — is the state in which the report can be made at all, and asking which git-fi is installed is the moment it answers a question already being asked. It shall not print on any other command: a second installation is not itself a fault, and a line on every run would be noise to whoever has a reason for it. stdout shall carry only the version string, so anything parsing it is unaffected. `GIT_FI_NO_HINTS` shall suppress it; the update notice's other suppressions (`UPDATE-03`) shall not, since a pipeline reporting which binary it ran is the case this exists for. An unreadable `PATH` entry, an unresolvable entry point, or no `git-fi` on `PATH` at all shall leave the command silent rather than failing it. A launcher is this copy when it leads to the same resolved entry point: a symlink resolves there, and a generated launcher names it — npm's relative to the launcher's own directory, pnpm's as a recorded `cmd-shim-target` (older pnpm launchers name a path relative to their directory that leaves `node_modules`, into pnpm's global directory).

## `UPDATE`

Expand All @@ -829,4 +829,4 @@ git-fi notifies the user when a newer version has been published to npm, without
- `UPDATE-02` git-fi shall refresh the cached latest version in a detached background process, throttled to at most once per 24 hours via the cache's `checkedAt` timestamp. The check shall be best-effort: a registry error, timeout, or spawn failure leaves the cache untouched and never surfaces or delays the command.
- `UPDATE-03` git-fi shall suppress both the notice and the background check when stdout is not a TTY, when `$CI` is set, when `--json` or `--bare` is used, when `$GIT_FI_NO_HINTS` or `$NO_UPDATE_NOTIFIER` is set, or when the running build is a dev build (`BUILD-01`). The notice names `git fi --update`, which installs the published global over the linked checkout and takes the trial down with it.
- `UPDATE-04` The cache shall live at `$XDG_CACHE_HOME/git-fi/update-check.json`, falling back to `~/.cache/git-fi/update-check.json`.
- `UPDATE-05` `--update` (`-u`) shall update the installed git-fi by running `npm install -g <package>@latest` with npm's stdio inherited, exiting with npm's exit code and adding no output of its own. Where the platform resolves npm through a `.cmd` shim (Windows), git-fi shall spawn it through the shell, which is the only path left: node finds nothing under the bare name and refuses a direct `.cmd` with `EINVAL`. A consequence is that a missing npm is then the shell's error to report rather than git-fi's, so the `Could not run npm` message is a POSIX-only guarantee. It shall run before the update notice and the pre-flight checks, so it works from any directory. It shall consult neither the cache nor the registry first: the throttle in `UPDATE-02` serves the passive notice, whereas `--update` is an explicit request to install now, and a redundant reinstall is a better answer than refusing one. It shall collide with the actions in `COMMAND-*` the way they collide with each other, and shall reject branch-name arguments.
- `UPDATE-05` `--update` (`-u`) shall update the installed git-fi with the package manager that installed it: `pnpm add -g <package>@latest` when pnpm did, otherwise `npm install -g <package>@latest`, with that tool's stdio inherited, exiting with its exit code and adding no output of its own. pnpm installed the running copy when the `node_modules` directory directly holding the package contains `.modules.yaml`, the marker pnpm writes into every `node_modules` it manages and npm never does; the check is made from both the path the launcher handed node and that path resolved, since pnpm's launcher passes a path through its global directory (where the marker is) and newer pnpm layouts resolve it into the store (where none is). Detection reads the file rather than asking pnpm, so it holds however pnpm and Node themselves were installed — standalone, corepack, npm, Homebrew, a version manager — whereas `pnpm root -g` answers for whichever pnpm the current directory's `packageManager` field selects. For the same reason pnpm shall run from the system temp directory, outside any project: run from a repo, corepack and pnpm's own version management would follow its `packageManager` field to another pnpm (with another global directory) or, in a repo pinned to another tool, refuse. Where pnpm installed git-fi but cannot be run, git-fi shall say so (`Could not run pnpm`) and how to put pnpm on `PATH`, rather than fall back to npm, which would install a second copy behind the one `PATH` reaches. Where the platform resolves npm or pnpm through a `.cmd` shim (Windows), git-fi shall spawn it through the shell, which is the only path left: node finds nothing under the bare name and refuses a direct `.cmd` with `EINVAL`. A consequence is that a missing tool is then the shell's error to report rather than git-fi's, so the `Could not run <tool>` message is a POSIX-only guarantee. It shall run before the update notice and the pre-flight checks, so it works from any directory. It shall consult neither the cache nor the registry first: the throttle in `UPDATE-02` serves the passive notice, whereas `--update` is an explicit request to install now, and a redundant reinstall is a better answer than refusing one. It shall collide with the actions in `COMMAND-*` the way they collide with each other, and shall reject branch-name arguments.
4 changes: 2 additions & 2 deletions STATUS.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ Install Integrity

| ID | Description | Status | Location |
|--------|----------------------------------|---------|--------------------------------|
| INSTALL-01 | `--version` reports a launcher ahead of this copy | Covered | `src/which.ts` (`gitFiOnPath`, `shadowingLauncher`, `shadowNotice`, `warnIfShadowed`), `src/index.ts` (`parseArgs`) |
| INSTALL-01 | `--version` reports a launcher ahead of this copy | Covered | `src/which.ts` (`gitFiOnPath`, `shadowingLauncher`, `isSameInstall`, `launcherTarget`, `shadowNotice`, `warnIfShadowed`), `src/index.ts` (`parseArgs`) |

## `UPDATE`

Expand All @@ -301,4 +301,4 @@ Update Notification
| UPDATE-02 | Throttled background check | Covered | `src/update-check.ts` (`notifyUpdate`), `src/update-worker.ts` |
| UPDATE-03 | Suppression conditions | Covered | `src/style.ts` (`hintsEnabled`), `src/update-check.ts` (`suppressed`), `src/build-info.ts` (`isDevBuild`) |
| UPDATE-04 | Cache location | Covered | `src/update-check.ts` (`cachePath`) |
| UPDATE-05 | `--update` installs the latest version | Covered | `src/update-check.ts` (`updateSelf`), `src/index.ts` (`parseArgs`, `main`) |
| UPDATE-05 | `--update` installs the latest version | Covered | `src/update-check.ts` (`updateSelf`), `src/package-manager.ts` (`PackageManager.detect`, `Npm`, `Pnpm`), `src/index.ts` (`parseArgs`, `main`) |
12 changes: 1 addition & 11 deletions docs/home.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,7 @@

A git plugin that maintains a temporary integration branch named `fi`. Merge multiple in-progress feature branches together to detect conflicts early and test features in collaboration — before they land on `main`.

## Get Started

<div class="gf-start">

```bash
npm install -g @gettyimages/git-fi # needs Node.js 22+ and git 2.41+
```

</div>

Then run your first integration with the [Quick Start](/quickstart), or follow a branch from first commit to `main` in the [Daily Workflow](/daily-workflow).
Install it and run your first integration with the [Quick Start](/quickstart), or follow a branch from first commit to `main` in the [Daily Workflow](/daily-workflow).

## The Problem

Expand Down
103 changes: 99 additions & 4 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,43 @@
color: var(--gf-heading);
max-width: 38em;
}
.markdown-section .gf-start pre { border-left: 3px solid var(--gf-accent); }
.markdown-section .gf-start .docsify-copy-code-button { opacity: 1; }
/* Install switch: the installSwitch plugin's command blocks, one per
package manager, framed as one code surface under the switch. */
.markdown-section .gf-install {
margin: 1em 0;
border: 1px solid var(--gf-divider);
border-radius: 10px;
background: var(--code-theme-background);
overflow: hidden;
}
.markdown-section .gf-install pre {
margin: 0;
border: 0;
border-radius: 0;
}
.gf-install-switch {
display: flex;
gap: 1.25rem;
padding: 0 1.25rem;
border-bottom: 1px solid var(--gf-divider);
}
.gf-install-switch button {
appearance: none;
background: none;
border: 0;
border-bottom: 2px solid transparent;
margin-bottom: -1px;
padding: 0.6rem 0 0.5rem;
font: 500 0.8rem/1 var(--code-font-family);
color: var(--gf-muted);
cursor: pointer;
transition: color 0.2s ease, border-color 0.2s ease;
}
.gf-install-switch button:hover { color: var(--gf-accent-hover); }
.gf-install-switch button[aria-pressed="true"] {
color: var(--gf-heading);
border-bottom-color: var(--gf-accent);
}

/* Visible focus ring (keyboard accessibility, >= 3:1) */
a:focus-visible,
Expand Down Expand Up @@ -270,7 +305,6 @@

@media screen and (min-width: 768px) {
.sidebar-toggle { display: none; }
.markdown-section .gf-start pre { font-size: 1.02rem; }
}
</style>
</head>
Expand Down Expand Up @@ -340,6 +374,67 @@
});
}

// The one place the docs say how each package manager installs git-fi.
// A page names only the package, in a fenced `install` block:
//
// ```install
// @gettyimages/git-fi
// ```
//
// and this expands it, before docsify renders the page, into one bash
// block per manager (so they get highlighting and a copy button like any
// other), then joins them under a switch that shows one at a time, so the
// copy button copies the command on screen. The first manager is the
// default; a reader's choice is remembered.
// Hand-rolled rather than docsify-tabs, which forgets the choice when
// the browser session ends and would need restyling to match the theme.
function installSwitch(hook) {
var MANAGERS = [
{ name: 'pnpm', command: 'pnpm add -g ' },
{ name: 'npm', command: 'npm install -g ' }
];
var KEY = 'git-fi.install-manager';
var remembered = null;
try { remembered = localStorage.getItem(KEY); } catch (e) { /* storage blocked */ }
hook.beforeEach(function (markdown) {
return markdown.replace(/^```install\r?\n(.+)\r?\n```$/gm, function (block, pkg) {
return '<div class="gf-install">\n\n' + MANAGERS.map(function (manager) {
return '```bash\n' + manager.command + pkg.trim() + '\n```';
}).join('\n\n') + '\n\n</div>';
});
});
hook.doneEach(function () {
document.querySelectorAll('.gf-install').forEach(function (box) {
var bar = document.createElement('div');
bar.className = 'gf-install-switch';
bar.setAttribute('role', 'group');
bar.setAttribute('aria-label', 'Package manager');
var options = Array.prototype.map.call(box.querySelectorAll('pre'), function (pre, i) {
var button = document.createElement('button');
button.type = 'button';
button.textContent = MANAGERS[i].name;
bar.appendChild(button);
return { name: MANAGERS[i].name, pre: pre, button: button };
});
box.insertBefore(bar, box.firstChild);
function show(chosen) {
options.forEach(function (o) {
o.pre.hidden = o !== chosen;
o.button.setAttribute('aria-pressed', String(o === chosen));
});
}
options.forEach(function (o) {
o.button.addEventListener('click', function () {
remembered = o.name;
try { localStorage.setItem(KEY, remembered); } catch (e) { /* storage blocked */ }
show(o);
});
});
show(options.find(function (o) { return o.name === remembered; }) || options[0]);
});
});
}

window.$docsify = {
name: 'git-fi',
// nameLink is intentionally omitted: Docsify defaults it to
Expand All @@ -359,7 +454,7 @@
noData: 'No results',
depth: 5
},
plugins: [searchPlainText, mermaidLinks],
plugins: [searchPlainText, mermaidLinks, installSwitch],
mermaidConfig: {
querySelector: '.mermaid',
theme: 'dark',
Expand Down
8 changes: 5 additions & 3 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

## Install

git-fi is a git subcommand: once the `git-fi` binary is on your `PATH`, invoke it as `git fi`. Requires Node.js >= 22 and git >= 2.41.0.
git-fi is a git subcommand: once the `git-fi` binary is on your `PATH`, invoke it as `git fi`.

```bash
npm install -g @gettyimages/git-fi
```install
@gettyimages/git-fi
```

Needs Node.js 22+ and git 2.41+.

Then turn on tab completion, so `git fi --add <TAB>` offers your branches. In zsh:

```zsh
Expand Down
17 changes: 6 additions & 11 deletions docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,23 @@

## Your git is older than 2.41.0

Every `git fi` command checks git first and stops if it is older than 2.41.0, naming the version it found. Where the git you have is the one your platform gives you (a long-support distribution, Apple's command line tools), install the last release that runs on git 2.13 and newer:
Every `git fi` command checks git first and stops if it is older than 2.41.0, naming the version it found. Where the git you have is the one your platform gives you (a long-support distribution, Apple's command line tools), install 1.2.2, the last release that runs on git 2.13 and newer:

```bash
npm install -g @gettyimages/git-fi@1.2.2
```install
@gettyimages/git-fi@1.2.2
```

## Upgrading from the Ruby gem

git-fi shipped as a Ruby gem through 0.9.3400163. `git fi` runs whichever `git-fi` comes first on your `PATH`, so remove the gem before you install the npm package:
git-fi shipped as a Ruby gem through 0.9.3400163. `git fi` runs whichever `git-fi` comes first on your `PATH`, so remove the gem before you [install](/quickstart#install) the package:

```bash
gem uninstall git-fi
npm install -g @gettyimages/git-fi
```

Use `gem uninstall` rather than deleting the gem's files.

Then open a new shell and run `git fi --version`. If it reports a `0.x` version, or fails with `cannot load such file` or `Maybe git-fi is broken?`, an older `git-fi` is ahead of npm's on your `PATH`. List them in resolution order and delete any outside npm's own prefix (`npm config get prefix`):
Then open a new shell and run `git fi --version`. If it reports a `0.x` version, or fails with `cannot load such file` or `Maybe git-fi is broken?`, an older `git-fi` is ahead of the one you installed on your `PATH`. List them in resolution order and delete any outside pnpm's bin directory (`pnpm bin -g`) or npm's own prefix (`npm config get prefix`):

```bash
which -a git-fi
Expand Down Expand Up @@ -57,11 +56,7 @@ git handles `--help` itself, before git-fi runs. Git for Windows opens an HTML p

## Update reports an unknown option

If `git fi --update` reports an unknown option, you're on a version that predates the flag. Update once with npm and you'll have it:

```bash
npm install -g @gettyimages/git-fi
```
If `git fi --update` reports an unknown option, you're on a version that predates the flag. Run the [install command](/quickstart#install) once, with the package manager you installed it with, and you'll have it.

## Tab completion offers filenames

Expand Down
Loading
Loading