Skip to content

feat(cli): add et git create-branch command - #5

Merged
seb4stien merged 2 commits into
mainfrom
feat/link-pr
Aug 18, 2026
Merged

feat(cli): add et git create-branch command#5
seb4stien merged 2 commits into
mainfrom
feat/link-pr

Conversation

@seb4stien

Copy link
Copy Markdown
Owner

Summary

Adds et git create-branch (aliased et git cb), which creates and
switches to a git branch named after the current task's Jira issue,
following Canonical's PR branch naming convention:
type/scope-short-description-jirakey (e.g. feat/tcp-wildcard-sni-support-isd-1234).

Details

  • Resolves the ticket via the active workspace's linked issue, or a
    -j/--jira KEY override (matching the existing et jira convention).
  • Prints the issue's clickable link and summary before any prompting.
  • Proposes a branch type from the issue's type/labels (Bugfix,
    Storyfeat, Taskchore; a documentation label always wins and
    defaults to docs), letting the user accept it or pick a different one
    from the fixed feat/fix/docs/chore/test/ci list — this becomes the
    branch's type/ prefix, which isn't otherwise freely editable.
  • Proposes the scope-short-description segment as a slug of the issue
    summary, freely editable at the prompt.
  • Appends the resolved Jira key (lowercased) as the trailing identifier,
    which is never editable.
  • Errors clearly if not run inside a git repo, or if a local branch with
    the computed name already exists.
  • Creates the branch from the current HEAD and switches to it
    (git checkout -b).

New/changed files

  • src/et/jira.py: new fetch_issue_basis (summary/type/labels).
  • src/et/git_branch.py (new): pure branch-naming logic + git subprocess
    helpers + create_branch_interactive orchestrator.
  • src/et/cli.py: new git Typer group with create-branch/cb.
  • README.md / CHANGELOG.md: documented the new command.
  • Tests: tests/test_git_branch.py (new), plus additions to
    tests/test_jira.py and tests/test_cli.py.

Testing

  • just lint / just static / just test all pass (381 tests, 90.5%
    coverage).

seb4stien and others added 2 commits August 18, 2026 16:51
Add `et git create-branch` (aliased `et git cb`) which creates and
switches to a git branch named after the current task's Jira issue,
following Canonical's `type/scope-short-description-jirakey` PR branch
naming convention.

- New `et.jira.fetch_issue_basis` fetches an issue's summary, type, and
  labels.
- New `et.git_branch` module: slugify(), default_branch_type() (Bug->fix,
  Story->feat, Task->chore, documentation label->docs), build_branch_name(),
  git subprocess helpers, and the create_branch_interactive() orchestrator.
- New `et git create-branch`/`et git cb` CLI command: resolves the ticket
  via the active workspace or -j/--jira KEY, prints the issue's clickable
  link and summary first, prompts to accept/override the branch type and
  edit the description slug, then creates and checks out the branch.
- Update README and CHANGELOG.
- Add unit/CLI tests for all of the above.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
test_git_create_branch_reports_no_active_workspace_error relied on the
developer's local ~/.config/et/config.yaml existing (load_config() was
never mocked), so it passed locally but failed in CI where no config
file exists. Mock et.cli.load_config like the other git-create-branch
tests do.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@seb4stien
seb4stien merged commit 58dfad4 into main Aug 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant