version_bump/git

Git access by shelling out to the git executable via shellout.

parse_log is the only PURE function here — it decodes a custom --pretty format that delimits fields with the ASCII unit separator (\u{1f}) and records with the ASCII record separator (\u{1e}). Those control characters never appear in normal commit text, so the parse is unambiguous without any quoting/escaping.

Values

pub fn commit(
  cwd: String,
  message: String,
  committer_name: String,
  committer_email: String,
) -> Result(Nil, error.ReleaseError)

Commit the staged changes with message, attributing the commit to the given identity (set per-command so a release works even when git’s user.name/ user.email aren’t configured, e.g. on a fresh CI runner). When nothing is staged this is a successful no-op, so a release with no file changes to commit doesn’t fail.

pub fn create_tag(
  cwd: String,
  tag: String,
  message: String,
) -> Result(Nil, error.ReleaseError)

Create an annotated tag at HEAD. The committer identity is set per-command (an annotated tag records a tagger, which git refuses to invent) so this works on a bare CI runner with no user.name/user.email configured — matching how the git plugin’s commit sets its identity.

pub fn current_branch(
  cwd: String,
) -> Result(String, error.ReleaseError)

The name of the currently checked-out branch.

pub fn get_remote_url(
  cwd: String,
  remote: String,
) -> Result(String, error.ReleaseError)

Resolve the fetch URL configured for a remote.

pub fn get_tags(
  cwd: String,
) -> Result(List(String), error.ReleaseError)

List all tags in the repository.

pub fn head_sha(
  cwd: String,
) -> Result(String, error.ReleaseError)

The full SHA of HEAD.

pub fn list_branches(
  cwd: String,
) -> Result(List(String), error.ReleaseError)

List local and remote-tracking branch names, with the leading origin/ (or any other remote prefix is preserved as-is) and decorations stripped.

pub fn log_since(
  cwd: String,
  from: option.Option(String),
) -> Result(List(commit_parser.Commit), error.ReleaseError)

Run git log [from..HEAD] with our pretty format and parse the result.

When from is None the entire history reachable from HEAD is returned; otherwise only commits in the from..HEAD range (i.e. reachable from HEAD but not from from).

pub fn parse_log(raw: String) -> List(commit_parser.Commit)

Parse the raw output of git log --pretty=<pretty_format> into commits.

PURE: no IO. Splits on the record separator, then each record on the unit separator. Records with the wrong number of fields (including the empty trailing record produced by the final record separator) are skipped.

pub fn push(
  cwd: String,
  remote: String,
  ref: String,
) -> Result(Nil, error.ReleaseError)

Push a single ref to a remote. ref may be a tag name, a branch name, or a <src>:<dst> refspec such as HEAD:main.

pub fn stage(
  cwd: String,
  paths: List(String),
) -> Result(Nil, error.ReleaseError)

Stage the given paths (git add -- <paths>).

Search Document