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 .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ concurrency:
env:
JJ_VERSION: '0.46.0'
JJ_SHA256: fce0271158e665ceb82dc66c5eb95b1728649094e9133074f3b5baece345fc08
JJ_LATEST_VERSION: '0.47.1'
JJ_LATEST_SHA256: d4b657f622ee50929c8916466dfa3d6a6c17a0a32b50e7b2c793707ec9ebcad7
JJ_LATEST_VERSION: '0.48.0'
JJ_LATEST_SHA256: 8b9f6a597d9c06a6e12cc4462438ce0b19c8bf493344423f8d66a099601ffd2e

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ There are two ways to use Ukemi:
- Linux (tested on Ubuntu 24.04 and Fedora 44).
- Windows
- macOS
- jj 0.40 or later. Ukemi downloads jj 0.47 when you agree.
- jj 0.46 or later. Ukemi downloads jj 0.48 when you agree.

## Suggested descriptions

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2454,7 +2454,7 @@
"Always create a Git worktree, so git and editor tools work in the workspace.",
"Never create a Git worktree. The workspace has only a `.jj` folder."
],
"markdownDescription": "Whether a new workspace in a colocated repository gets its own Git worktree. Needs jj 0.46 or later. Has no effect in a repository that is not colocated."
"markdownDescription": "Whether a new workspace in a colocated repository gets its own Git worktree. Has no effect in a repository that is not colocated."
},
"ukemi.changedFilesView": {
"type": "string",
Expand Down
6 changes: 1 addition & 5 deletions src/app/commands/workspaceCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,7 @@ export async function addWorkspace(
)
return
}
const colocate = workspaceColocation(
config.workspaceGitWorktree,
model.repo.isColocated,
config.workspaceGitWorktree !== 'auto' && (await model.repo.canColocateWorkspaces()),
)
const colocate = workspaceColocation(config.workspaceGitWorktree, model.repo.isColocated)
const created = await env.operations.run('Create workspace', model, async () => {
await model.repo.addWorkspace(path, name, chosen.revision, colocate)
return true
Expand Down
28 changes: 14 additions & 14 deletions src/jj/binary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { isVersionAtLeast, parseVersion, type JjVersion } from './parse'

const execFileAsync = promisify(execFile)

export const MIN_JJ_VERSION: JjVersion = { major: 0, minor: 40, patch: 0 }
export const MIN_JJ_VERSION: JjVersion = { major: 0, minor: 46, patch: 0 }
const VERSION_PROBE_TIMEOUT_MS = 5_000

export interface ReleaseAsset {
Expand All @@ -21,31 +21,31 @@ export interface ReleaseAsset {
// The official builds, by Node's `${process.platform}-${process.arch}`. The digests are the ones
// GitHub lists for the release assets.
export const PINNED_RELEASE = {
version: '0.47.1',
version: '0.48.0',
assets: {
'linux-x64': {
name: 'jj-v0.47.1-x86_64-unknown-linux-musl.tar.gz',
sha256: 'd4b657f622ee50929c8916466dfa3d6a6c17a0a32b50e7b2c793707ec9ebcad7',
name: 'jj-v0.48.0-x86_64-unknown-linux-musl.tar.gz',
sha256: '8b9f6a597d9c06a6e12cc4462438ce0b19c8bf493344423f8d66a099601ffd2e',
},
'linux-arm64': {
name: 'jj-v0.47.1-aarch64-unknown-linux-musl.tar.gz',
sha256: '0f300e1576de8dabe0a9dedf0b87ae44f8accea5cf54d9a342a51061c1fb1bcd',
name: 'jj-v0.48.0-aarch64-unknown-linux-musl.tar.gz',
sha256: '70e76772b37f5ef6bab8f896958b9bff9c9ace880b7219f7ca22a31887603dd9',
},
'darwin-x64': {
name: 'jj-v0.47.1-x86_64-apple-darwin.tar.gz',
sha256: 'ce7ac70c3b7cf90f2273b4fa62d24576727c5fd55c60dc3820221c05320c7589',
name: 'jj-v0.48.0-x86_64-apple-darwin.tar.gz',
sha256: '1e7073ad1a591eec68cbdbe00706fcb2f1078505c5f687af3cb3b66e8a8d32f7',
},
'darwin-arm64': {
name: 'jj-v0.47.1-aarch64-apple-darwin.tar.gz',
sha256: '50129b527f7cd6aef82aebd4bb2b670bb56766adc509ef3279c4327aa3592255',
name: 'jj-v0.48.0-aarch64-apple-darwin.tar.gz',
sha256: 'b07c08bb399066b4997322f368a2b55c0cac904e20027a2cd8ba0dbbcca65ede',
},
'win32-x64': {
name: 'jj-v0.47.1-x86_64-pc-windows-msvc.zip',
sha256: '72f9f80bc99d07a7f48d5f219cf5bab91f7e906e4b53f6c827948e646cd1152f',
name: 'jj-v0.48.0-x86_64-pc-windows-msvc.zip',
sha256: 'aa752a2ec0f9c71495b7f8a2aaf26c0f5569597a2dcd42b9172089e2da4ca6c5',
},
'win32-arm64': {
name: 'jj-v0.47.1-aarch64-pc-windows-msvc.zip',
sha256: '07f3cf6ed6db95f12be6c79c76aff948689375a9f201f521df4468d0a0c5de85',
name: 'jj-v0.48.0-aarch64-pc-windows-msvc.zip',
sha256: 'acfdedc29abb097c974c23e4cc964bf8d9a0467afdc2ffbe1bed88038c6a9bc4',
},
} as Record<string, ReleaseAsset>,
}
Expand Down
22 changes: 10 additions & 12 deletions src/jj/repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ export const GRAPH_PAGE_SIZE = 500
export const MAX_EVOLUTION_ENTRIES = 200
// The first jj whose templates can evaluate a revset, which elidedHeads needs.
export const TEMPLATE_REVSET_VERSION: JjVersion = { major: 0, minor: 47, patch: 0 }
// The first jj whose `workspace add` takes --colocate and --no-colocate.
export const COLOCATED_WORKSPACE_VERSION: JjVersion = { major: 0, minor: 46, patch: 0 }

export interface LogPage {
commits: Commit[]
Expand Down Expand Up @@ -146,7 +144,10 @@ export class JjRepo {

private mutate(
args: readonly string[],
options: Pick<RunOptions, 'stdin' | 'timeoutMs' | 'env' | 'background'> = {},
options: Pick<
RunOptions,
'stdin' | 'timeoutMs' | 'env' | 'background' | 'expectedWarning'
> = {},
) {
if (this.operationId !== null) {
throw new Error('jj commands cannot run at an old operation')
Expand Down Expand Up @@ -683,8 +684,12 @@ export class JjRepo {
return this.mutate(['file', 'untrack', ...paths.map(rootFileset)])
}

// jj before 0.48 refuses a backwards move without --allow-backwards; 0.48 ignores the flag and
// warns about the move instead.
setBookmark(name: string, commitId: string) {
return this.mutate(['bookmark', 'set', jjString(name), '-r', commitId, '--allow-backwards'])
return this.mutate(['bookmark', 'set', jjString(name), '-r', commitId, '--allow-backwards'], {
expectedWarning: /^Moving bookmarks backwards or sideways/,
})
}

advanceBookmark(commitId: string) {
Expand Down Expand Up @@ -777,14 +782,7 @@ export class JjRepo {
return this.mutate(['op', 'revert', operationId(id)])
}

// Whether `workspace add` can be told to create a Git worktree or not.
async canColocateWorkspaces(): Promise<boolean> {
const version = await this.runner.version()
return version !== null && isVersionAtLeast(version, COLOCATED_WORKSPACE_VERSION)
}

// `colocate` passes --colocate or --no-colocate. Undefined leaves the choice to jj, and needs
// COLOCATED_WORKSPACE_VERSION otherwise.
// `colocate` passes --colocate or --no-colocate. Undefined leaves the choice to jj.
addWorkspace(path: string, name: string, revision: string, colocate?: boolean) {
const flag = colocate === undefined ? [] : [colocate ? '--colocate' : '--no-colocate']
return this.mutate(['workspace', 'add', '--name', name, '-r', revision, ...flag, path])
Expand Down
7 changes: 5 additions & 2 deletions src/jj/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ const INDEX_LOCK_DELAY_MS = 500
// How long jj and its helpers get to end after SIGTERM before they are killed.
const KILL_GRACE_MS = 3_000

const GLOBAL_ARGS = ['--color=never', '--no-pager']
// Word wrap would break the JSON that the templates print.
const GLOBAL_ARGS = ['--color=never', '--no-pager', '--config=ui.log-word-wrap=false']

export interface RunOptions {
cwd: string
Expand All @@ -27,6 +28,8 @@ export interface RunOptions {
env?: Readonly<Record<string, string>>
// Nobody waits for the result, like a snapshot or an auto-fetch: warnings are only logged.
background?: boolean
// A warning about what the caller asked for on purpose: it is only logged.
expectedWarning?: RegExp
}

export interface JjWarning {
Expand Down Expand Up @@ -401,7 +404,7 @@ export class JjRunner {
const quiet = options.background || options.ignoreWorkingCopy
for (const text of stderrWarnings(stderr)) {
this.logger.warn(`${repoTag(options.cwd)} ${text}`)
if (!quiet) {
if (!quiet && !options.expectedWarning?.test(text)) {
this.warningHandler?.({ cwd: options.cwd, args: options.args, text })
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/repo/workspaceItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,12 @@ export function workspaceFolder(parent: string, repoRoot: string, name: string):
}

// The --colocate choice for `workspace add`: undefined lets jj decide. It applies only to a
// colocated repository and a jj that has the flag.
// colocated repository.
export function workspaceColocation(
mode: 'auto' | 'always' | 'never',
isColocated: boolean,
canColocate: boolean,
): boolean | undefined {
if (mode === 'auto' || !isColocated || !canColocate) {
if (mode === 'auto' || !isColocated) {
return undefined
}
return mode === 'always'
Expand Down
40 changes: 36 additions & 4 deletions test/integration/repo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -760,10 +760,7 @@ describe('mutations', () => {
expect(names).toEqual(['default', 'second'])
})

test('addWorkspace creates a Git worktree or not, as asked', async (ctx) => {
if (!(await repo.canColocateWorkspaces())) {
ctx.skip()
}
test('addWorkspace creates a Git worktree or not, as asked', async () => {
const withWorktree = join(fixture.dir, 'repo-git')
const plain = join(fixture.dir, 'repo-plain')

Expand Down Expand Up @@ -812,6 +809,41 @@ describe('bookmark advance', () => {
})
})

describe('word wrap', () => {
test('reads long descriptions when the user wraps log output', async () => {
jj(root, 'config', 'set', '--repo', 'ui.log-word-wrap', 'true')
const description = Array.from({ length: 60 }, () => 'word').join(' ')
jj(root, 'describe', '-m', description)

expect((await current()).description.trim()).toBe(description)
})
})

describe('bookmark set', () => {
test('moving a bookmark backwards reports no warning', async () => {
writeFile(root, 'a.txt', 'a\n')
jj(root, 'describe', '-m', 'parent')
const parent = await current()
jj(root, 'new')
writeFile(root, 'b.txt', 'b\n')
jj(root, 'describe', '-m', 'child')
const child = await current()
const runner = makeRunner()
const warnings: string[] = []
runner.onWarning((warning) => warnings.push(warning.text))
const watched = new JjRepo(root, runner)
await watched.setBookmark('feature', child.commitId)

await watched.setBookmark('feature', parent.commitId)

const feature = (await watched.bookmarkList()).find(
(bookmark) => bookmark.name === 'feature' && bookmark.remote === null,
)
expect(feature?.commitId).toBe(parent.commitId)
expect(warnings).toEqual([])
})
})

describe('bookmark rename and untrack', () => {
test('renameBookmark keeps the target under the new name', async () => {
writeFile(root, 'a.txt', 'a\n')
Expand Down
13 changes: 12 additions & 1 deletion test/unit/runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ describe('JjRunner environment', () => {
})

describe('JjRunner warnings', () => {
async function warningsOf(options: { background?: boolean; ignoreWorkingCopy?: boolean }) {
async function warningsOf(options: {
background?: boolean
ignoreWorkingCopy?: boolean
expectedWarning?: RegExp
}) {
const dir = mkdtempSync(join(tmpdir(), 'ukemi-runner-'))
const fake = join(dir, 'jj')
writeFileSync(
Expand Down Expand Up @@ -79,6 +83,13 @@ describe('JjRunner warnings', () => {
expect((await warningsOf({ ignoreWorkingCopy: true })).shown).toEqual([])
expect((await warningsOf({ background: true })).logged).toHaveLength(1)
})

test('only logs the warning the caller expects', async () => {
const expected = await warningsOf({ expectedWarning: /^No matching bookmarks/ })
expect(expected.shown).toEqual([])
expect(expected.logged).toHaveLength(1)
expect((await warningsOf({ expectedWarning: /^Something else/ })).shown).toHaveLength(1)
})
})

describe('stderrWarnings', () => {
Expand Down
9 changes: 4 additions & 5 deletions test/unit/workspaces.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,10 @@ describe('workspace folder', () => {

describe('workspaceColocation', () => {
test('passes a flag only for a colocated repository and a jj that has it', () => {
expect(workspaceColocation('always', true, true)).toBe(true)
expect(workspaceColocation('never', true, true)).toBe(false)
expect(workspaceColocation('auto', true, true)).toBeUndefined()
expect(workspaceColocation('never', false, true)).toBeUndefined()
expect(workspaceColocation('always', true, false)).toBeUndefined()
expect(workspaceColocation('always', true)).toBe(true)
expect(workspaceColocation('never', true)).toBe(false)
expect(workspaceColocation('auto', true)).toBeUndefined()
expect(workspaceColocation('never', false)).toBeUndefined()
})
})

Expand Down
Loading