@bridgebrew/project 0.0.2 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/branches.ts +13 -5
- package/browser/branches.tsx +5 -4
- package/package.json +5 -4
package/branches.ts
CHANGED
|
@@ -375,7 +375,9 @@ export function createBranches(host: BranchesHost, settings: Settings = {}) {
|
|
|
375
375
|
/** The remote git works with from `folder` (bridge#522): its branch's upstream's, else the only one, else `origin`;
|
|
376
376
|
* `undefined` when that remote does not exist. */
|
|
377
377
|
const remoteOf = async (folder: string) => {
|
|
378
|
-
|
|
378
|
+
// Its full name: the short form is `heads/<name>` beside a tag of the same name (plugins#198).
|
|
379
|
+
const head = await git(folder, ['symbolic-ref', '--quiet', 'HEAD']).catch(() => '');
|
|
380
|
+
const branch = head.replace(/^refs\/heads\//, '');
|
|
379
381
|
const tracked = branch && (await git(folder, ['config', '--get', `branch.${branch}.remote`]).catch(() => ''));
|
|
380
382
|
const names = (await git(folder, ['remote']).catch(() => '')).split('\n').filter(Boolean);
|
|
381
383
|
const name = tracked && names.includes(tracked) ? tracked : names.length === 1 ? names[0] : 'origin';
|
|
@@ -748,9 +750,14 @@ export function createBranches(host: BranchesHost, settings: Settings = {}) {
|
|
|
748
750
|
// From the remote's default branch, fetched now, else as fetched last (offline: bridge#540); its local one only
|
|
749
751
|
// without a remote.
|
|
750
752
|
if (base.remote)
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
753
|
+
// Its full ref: a tag of the same name would be fetched in its place, the branch left as it was (plugins#198).
|
|
754
|
+
await remoteGit(folder, [
|
|
755
|
+
'fetch',
|
|
756
|
+
'--quiet',
|
|
757
|
+
'--no-auto-maintenance',
|
|
758
|
+
base.remote,
|
|
759
|
+
`refs/heads/${base.name}`,
|
|
760
|
+
]).catch(() => undefined);
|
|
754
761
|
const from = base.remote && (await resolves(folder, base.ref)) ? base.ref : `refs/heads/${base.name}`;
|
|
755
762
|
const kept = await git(folder, ['branch', '--list', name]);
|
|
756
763
|
const head = await git(folder, ['rev-parse', `${kept ? `refs/heads/${name}` : from}^{commit}`]);
|
|
@@ -892,7 +899,8 @@ export function createBranches(host: BranchesHost, settings: Settings = {}) {
|
|
|
892
899
|
if (branch.isDefault && !confirmed)
|
|
893
900
|
throw new Error(`pushing ${branch.name}, the default branch, needs a confirmation`);
|
|
894
901
|
const remote = (await remoteOf(branch.folder)) ?? 'origin';
|
|
895
|
-
|
|
902
|
+
// Its full ref: a tag of the same name makes the short one ambiguous, and git refuses it (plugins#198).
|
|
903
|
+
await remoteGit(branch.folder, ['push', '-u', remote, `refs/heads/${branch.name}`]).catch((error: unknown) => {
|
|
896
904
|
throw new Error(`${branch.name} is not pushed, git refused: ${reason(error)}`);
|
|
897
905
|
});
|
|
898
906
|
};
|
package/browser/branches.tsx
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// branch in its worktree (`.worktrees/<name>`), one line each in the kit's Table: its name, then marks in slots of their
|
|
3
3
|
// own (Active, its commits behind | ahead of the default branch, its uncommitted changes as GitHub's diffstat, its pull
|
|
4
4
|
// request; commits to push or pull show through the Git button), then its actions, right-aligned in one order: the Git
|
|
5
|
-
// button and its menu (`@
|
|
5
|
+
// button and its menu (`@bridgebrew/session-ui/git-actions`), Activate, and "…" for the rest (Delete, with why it is
|
|
6
6
|
// refused). New branch starts one from the default branch; a selected branch takes a prompt whose session works on it.
|
|
7
7
|
// Activate makes a branch the active one: everything Bridge loads from the project (its plugins, host-level code such as
|
|
8
8
|
// the Bridge UI kit) follows it, without a restart. Data and actions from this plugin's `/branches` routes
|
|
@@ -42,13 +42,13 @@ import {
|
|
|
42
42
|
} from '@bridge/ui';
|
|
43
43
|
import type { Context } from 'cordis';
|
|
44
44
|
import type {} from '@bridge/ui-renderer/client';
|
|
45
|
-
import { SessionPrompt } from '@
|
|
45
|
+
import { SessionPrompt } from '@bridgebrew/session-ui/prompt';
|
|
46
46
|
import {
|
|
47
47
|
GitActions,
|
|
48
48
|
type BranchesAnswer,
|
|
49
49
|
type BranchesRoute,
|
|
50
50
|
type GitBranch,
|
|
51
|
-
} from '@
|
|
51
|
+
} from '@bridgebrew/session-ui/git-actions';
|
|
52
52
|
|
|
53
53
|
/** This plugin's Branches route of project `node` in workspace `slug`, or one of its actions. */
|
|
54
54
|
export const projectBranchesRoute: BranchesRoute = (slug, node, action) =>
|
|
@@ -496,7 +496,8 @@ export function Branches({ ctx, node }: { ctx: Context; node: string }) {
|
|
|
496
496
|
<GitActions
|
|
497
497
|
slug={slug}
|
|
498
498
|
node={node}
|
|
499
|
-
|
|
499
|
+
// Without the GitHub plugin, no pull request is offered: the notice above says why (bridge#557).
|
|
500
|
+
branch={view.github === 'missing' ? { ...branch, pullRequests: false } : branch}
|
|
500
501
|
route={projectBranchesRoute}
|
|
501
502
|
disabled={busy || !!branch.job?.running}
|
|
502
503
|
onAnswer={(answer) =>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bridgebrew/project",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "A project is a folder of work with its bridge.yml, and a node with its own sessions: code, documents, anything; Bridge plugins can be made there too.",
|
|
6
6
|
"keywords": [
|
|
@@ -88,13 +88,14 @@
|
|
|
88
88
|
"/branches/pr": 120000,
|
|
89
89
|
"/branches/remove": 120000
|
|
90
90
|
},
|
|
91
|
-
"provenance": "official"
|
|
91
|
+
"provenance": "official",
|
|
92
|
+
"placement": "workspace"
|
|
92
93
|
},
|
|
93
94
|
"dependencies": {
|
|
95
|
+
"@bridgebrew/session-ui": "0.0.1",
|
|
94
96
|
"zod": "4.6.5"
|
|
95
97
|
},
|
|
96
98
|
"peerDependencies": {
|
|
97
|
-
"@bridge/session-ui": ">=0.0.1",
|
|
98
99
|
"@bridge/ui": ">=0.0.1",
|
|
99
100
|
"cordis": "4.0.0-rc.11",
|
|
100
101
|
"react": "19.3.0"
|
|
@@ -105,6 +106,6 @@
|
|
|
105
106
|
"typecheck": "bridge plugin check ."
|
|
106
107
|
},
|
|
107
108
|
"engines": {
|
|
108
|
-
"bridge": ">=0.0.1-nightly.
|
|
109
|
+
"bridge": ">=0.0.1-nightly.20261119.2"
|
|
109
110
|
}
|
|
110
111
|
}
|