# orca.source

> A module of Orca's API.

Where a pipeline binary's code came from: its git repository and commit, given at build time.

mojo build -D ORCA_SOURCE=https://github.com/me/lake \
        -D ORCA_COMMIT=$(git rev-parse HEAD) \
        -D ORCA_DIRTY=$(git diff --quiet HEAD && echo 0 || echo 1) ...

`describe` reports them, `orca register` and each run record them as a
version of the pipeline (`orca.pipeline_versions`), and `orca ui` links a
run to the commit it ran. A binary built without them has an empty source
and is shown as such.

## Functions

### `source_repo`

```mojo
def source_repo() -> String
```

### `source_commit`

```mojo
def source_commit() -> String
```

The commit, or "" if what was defined isn't hex. `mojo build -D` reads a value of digits alone as a number, which a real SHA, with 40 characters, practically never is.

### `is_hex`

```mojo
def is_hex(s: String) -> Bool
```

### `source_dirty`

```mojo
def source_dirty() -> Bool
```

Whether the tree it was built from had changes the commit lacks.

### `web_url`

```mojo
def web_url(repo: String) -> String
```

`repo`'s page, for the forms a remote is written in: https with or without `.git`, and `git@host:owner/name`; "" for anything else.

### `commit_url`

```mojo
def commit_url(repo: String, commit: String) -> String
```

The commit's tree on its host, or "" when either is unknown. GitHub, GitLab and Gitea all serve a tree at `<repo>/tree/<sha>`.
