{"record":{"id":"6e7eedaeddd7f58d","repo":"nodejs/node","slug":"couldn-t-find-curent-branch","errorCode":null,"errorMessage":"Couldn't find curent branch.","messagePattern":"Couldn't find curent branch\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"deps/v8/tools/release/git_recipes.py","lineNumber":162,"sourceCode":"\n  def GitChangedFiles(self, git_hash, **kwargs):\n    assert git_hash\n    try:\n      files = self.Git(MakeArgs([\"diff --name-only\",\n                                 git_hash,\n                                 \"%s^\" % git_hash]), **kwargs)\n      return map(str.strip, files.splitlines())\n    except GitFailedException:  # pragma: no cover\n      # Git fails using \"^\" at branch roots.\n      return []\n\n\n  @Strip\n  def GitCurrentBranch(self, **kwargs):\n    for line in self.Git(\"status -s -b -uno\", **kwargs).strip().splitlines():\n      match = re.match(r\"^## (.+)\", line)\n      if match: return match.group(1)\n    raise Exception(\"Couldn't find curent branch.\")  # pragma: no cover\n\n  @Strip\n  def GitLog(self, n=0, format=\"\", grep=\"\", git_hash=\"\", parent_hash=\"\",\n             branch=\"\", path=None, reverse=False, **kwargs):\n    assert not (git_hash and parent_hash)\n    args = [\"log\"]\n    if n > 0:\n      args.append(\"-%d\" % n)\n    if format:\n      args.append(\"--format=%s\" % format)\n    if grep:\n      args.append(\"--grep=\\\"%s\\\"\" % grep.replace(\"\\\"\", \"\\\\\\\"\"))\n    if reverse:\n      args.append(\"--reverse\")\n    if git_hash:\n      args.append(git_hash)\n    if parent_hash:\n      args.append(\"%s^\" % parent_hash)","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/v8/tools/release/git_recipes.py#L144-L180","documentation":"GitCurrentBranch parses `git status -s -b -uno` and looks for a line matching `^## (.+)` (the branch-tracking summary). If no such line appears, the repo is in a state without a current branch (detached HEAD, empty/unborn repo, or cwd is not a git worktree).","triggerScenarios":"Running release scripts on a detached HEAD, on a freshly-init'd repo with no commits, or outside any git worktree.","commonSituations":"CI checkout in detached-HEAD mode; release tooling run on a tag/SHA instead of a branch; wrong cwd; empty repo.","solutions":["Check out a real branch: `git switch -c <branch>` or `git checkout <branch>`.","Avoid running release scripts on a detached HEAD.","Confirm the cwd is inside the right worktree (has a .git)."],"exampleFix":"// before\n# repo is in detached HEAD\nv8/tools/release/push_to_candidates.py ...\n// after\ngit checkout main\nv8/tools/release/push_to_candidates.py ...","handlingStrategy":"validation","validationCode":"import subprocess\nout = subprocess.run(['git', 'status', '-s', '-b', '-uno'],\n                     capture_output=True, text=True, check=True).stdout\nassert any(line.startswith('## ') for line in out.splitlines()), (\n    'no current branch; check out a branch (not detached HEAD)')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always check out a real branch before running release scripts.","In CI, avoid detached-HEAD checkouts for branch-aware tooling.","Verify cwd is inside the intended worktree."],"tags":["git","release-tools","v8","branch"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}