Skip to content

Commit 6120fbd

Browse files
committed
Merge origin/main: sync sandbox policy and workflow guards
2 parents 8851d18 + 0b6be0f commit 6120fbd

4 files changed

Lines changed: 29 additions & 6 deletions

File tree

.github/workflows/preview-build.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,13 @@ jobs:
189189
release:
190190
name: Publish prerelease (all targets)
191191
needs: [build]
192-
if: github.event_name == 'pull_request' && github.event.pull_request.head.ref != 'upstream-merge'
192+
# Only publish for PRs from the main repo (not forks) to avoid permission failures.
193+
# Fixes: https://github.com/just-every/code/issues/355
194+
# Fixes: https://github.com/just-every/code/issues/356
195+
if: >-
196+
github.event_name == 'pull_request' &&
197+
github.event.pull_request.head.ref != 'upstream-merge' &&
198+
github.event.pull_request.head.repo.full_name == github.repository
193199
runs-on: ubuntu-latest
194200
steps:
195201
- name: Resolve slug and next tag
@@ -327,6 +333,11 @@ jobs:
327333
comment:
328334
name: Post Artifact Links
329335
needs: [build, release]
336+
# Only run if release job ran (which is conditional on non-fork PRs)
337+
if: >-
338+
github.event_name == 'pull_request' &&
339+
github.event.pull_request.head.ref != 'upstream-merge' &&
340+
github.event.pull_request.head.repo.full_name == github.repository
330341
runs-on: ubuntu-latest
331342
steps:
332343
- name: Resolve slug and latest tag

code-rs/core/src/codex.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,13 @@ fn to_proto_sandbox_policy(policy: SandboxPolicy) -> ProtoSandboxPolicy {
167167
network_access,
168168
exclude_tmpdir_env_var,
169169
exclude_slash_tmp,
170-
allow_git_writes: _,
170+
allow_git_writes,
171171
} => ProtoSandboxPolicy::WorkspaceWrite {
172172
writable_roots,
173173
network_access,
174174
exclude_tmpdir_env_var,
175175
exclude_slash_tmp,
176+
allow_git_writes,
176177
},
177178
}
178179
}

code-rs/protocol/src/protocol.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,16 @@ pub enum SandboxPolicy {
271271
/// writable roots on UNIX. Defaults to `false`.
272272
#[serde(default)]
273273
exclude_slash_tmp: bool,
274+
275+
/// When true, do not protect the top-level `.git` folder under a writable root.
276+
/// Defaults to true to match historical behavior that permits Git writes.
277+
#[serde(default = "default_true_bool")]
278+
allow_git_writes: bool,
274279
},
275280
}
276281

282+
const fn default_true_bool() -> bool { true }
283+
277284
/// A writable root path accompanied by a list of subpaths that should remain
278285
/// read‑only even when the root is writable. This is primarily used to ensure
279286
/// top‑level VCS metadata directories (e.g. `.git`) under a writable root are
@@ -328,6 +335,7 @@ impl SandboxPolicy {
328335
network_access: false,
329336
exclude_tmpdir_env_var: false,
330337
exclude_slash_tmp: false,
338+
allow_git_writes: true,
331339
}
332340
}
333341

@@ -363,6 +371,7 @@ impl SandboxPolicy {
363371
writable_roots,
364372
exclude_tmpdir_env_var,
365373
exclude_slash_tmp,
374+
allow_git_writes,
366375
network_access: _,
367376
} => {
368377
// Start from explicitly configured writable roots.
@@ -400,9 +409,11 @@ impl SandboxPolicy {
400409
.into_iter()
401410
.map(|writable_root| {
402411
let mut subpaths = Vec::new();
403-
let top_level_git = writable_root.join(".git");
404-
if top_level_git.is_dir() {
405-
subpaths.push(top_level_git);
412+
if !allow_git_writes {
413+
let top_level_git = writable_root.join(".git");
414+
if top_level_git.is_dir() {
415+
subpaths.push(top_level_git);
416+
}
406417
}
407418
WritableRoot {
408419
root: writable_root,

code-rs/tui/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ pub async fn run_main(
325325
let (sandbox_mode, approval_policy) = if cli.full_auto {
326326
(
327327
Some(SandboxMode::WorkspaceWrite),
328-
Some(AskForApproval::OnRequest),
328+
Some(AskForApproval::OnFailure),
329329
)
330330
} else if cli.dangerously_bypass_approvals_and_sandbox {
331331
(

0 commit comments

Comments
 (0)