{"record":{"id":"d68d22d6507ea84c","repo":"gitbutlerapp/gitbutler","slug":"gerrit-push-flags-wip-ready-hashtag-tag","errorCode":null,"errorMessage":"Gerrit push flags (--wip, --ready, --hashtag/--tag, --topic, --topic-from-branch, --private) can only be used when gerrit_mode is enabled for this repository","messagePattern":"Gerrit push flags \\(--wip, --ready, --hashtag/--tag, --topic, --topic-from-branch, --private\\) can only be used when gerrit_mode is enabled for this repository","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/push.rs","lineNumber":1045,"sourceCode":"    branches_info.sort_by(|a, b| a.2.cmp(&b.2).then(a.0.cmp(&b.0)));\n\n    Ok(branches_info)\n}\n\npub fn get_gerrit_flags(\n    args: &Command,\n    branch_name: &str,\n    gerrit_mode: bool,\n) -> anyhow::Result<Vec<but_gerrit::PushFlag>> {\n    let has_gerrit_flag = args.wip\n        || args.ready\n        || !args.hashtag.is_empty()\n        || args.topic.is_some()\n        || args.topic_from_branch\n        || args.private;\n\n    if has_gerrit_flag && !gerrit_mode {\n        return Err(anyhow::anyhow!(\n            \"Gerrit push flags (--wip, --ready, --hashtag/--tag, --topic, --topic-from-branch, --private) can only be used when gerrit_mode is enabled for this repository\"\n        ));\n    }\n\n    if !gerrit_mode {\n        return Ok(vec![]);\n    }\n\n    let mut flags = Vec::new();\n\n    // Handle Wip/Ready - Ready is default if neither is specified\n    if args.wip {\n        flags.push(but_gerrit::PushFlag::Wip);\n    } else {\n        // Default to Ready, or explicit Ready\n        flags.push(but_gerrit::PushFlag::Ready);\n    }\n","sourceCodeStart":1027,"sourceCodeEnd":1063,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/push.rs#L1027-L1063","documentation":"get_gerrit_flags throws this when Gerrit-specific push flags (--wip, --ready, --hashtag/--tag, --topic, --topic-from-branch, --private) are used while gerrit_mode is not enabled for the repository. These flags only have meaning for Gerrit's push semantics (refs/for/, topics, WIP markers), so the CLI rejects them outright to prevent silently ignored options.","triggerScenarios":"Running `but push --wip`, `--ready`, `--topic x`, `--topic-from-branch`, `--private`, or `--hashtag y` (push_single_branch_impl path) on a repo where gerrit_mode is disabled in its configuration.","commonSituations":"Copy-pasting push commands between Gerrit and non-Gerrit repos, forgetting to enable gerrit_mode after cloning a Gerrit project, or CI scripts assuming Gerrit flags are universally accepted.","solutions":["Enable gerrit mode for the repository in GitButler config (repo-level gerrit_mode setting)","Remove the Gerrit-specific flags if the remote is not a Gerrit server","Confirm the push target is actually Gerrit; for GitHub/GitLab use their native review flags instead"],"exampleFix":"// before\nbut push --topic my-topic  // error: requires gerrit_mode\n// after\nbut config gerrit_mode true\nbut push --topic my-topic","handlingStrategy":"validation","validationCode":"// check gerrit_mode before passing Gerrit flags\nconst gerrit = await runBut(['config', 'gerrit_mode', '--get']);\nif (gerrit !== 'true' && gerritFlags.length > 0) {\n  throw new Error('Enable gerrit_mode or drop Gerrit flags');\n}","typeGuard":"function canUseGerritFlags(cfg: { gerrit_mode: boolean }): boolean {\n  return cfg.gerrit_mode === true;\n}","tryCatchPattern":"try {\n  await runBut(['push', ...gerritFlags]);\n} catch (e) {\n  if (/can only be used when gerrit_mode is enabled/.test(e.message)) {\n    await runBut(['config', 'gerrit_mode', 'true']);\n    return retry();\n  }\n  throw e;\n}","preventionTips":["Enable gerrit_mode once per Gerrit repository","Keep separate command templates for Gerrit vs non-Gerrit remotes","Audit CI scripts for Gerrit flags before pointing them at new remotes"],"tags":["cli","push","gerrit","flags","config"],"backgroundTag":"feature-not-enabled","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}