Get started
Edit on GitHub

Command Reference: pr

cml pr [options] <pathspec>...

Commit specified files to a new branch and create a pull request. If sending a report afterwards, consider using cml send-comment --pr --update.

ⓘ Pull requests created with cml pr won't trigger a new CI/CD run, thereby preventing an infinite chain of runs.

ⓘ Files to commit can be specified using any syntax supported by Git pathspec.


Any generic option in addition to:

  • --merge, --rebase, or --squash: Try to merge, rebase, or squash-merge the created PR after CI tests pass.
  • --md: Produce output in markdown format ([CML Pull/Merge Request](url) instead of url).
  • --remote=<name or URL>: Git remote name or URL [default: origin].
  • --user-email=<address>: Git user email for commits [default:].
  • --user-name=<...>: Git user name for commits [default: Olivaw[bot]].


Commit all files in current working directory

cml pr .

Automatically merge pull requests

date > output.txt
cml pr --auto-merge output.txt

The --merge, --rebase, and --squash options enable auto–merge (GitHub) or merge when pipeline succeeds (GitLab) to merge the pull request as soon as checks succeed. If waiting for checks isn't supported, cml pr will try to merge the pull request immediately.

Command internals

cml pr "**/*.py" "**/*.json"

is roughly equivalent to:

SHA="$(git log -n1 --format=%h)"
BASE="$(git branch)"

git checkout "${BASE}-cml-pr-${SHA}"

if [[ $(git ls-remote --exit-code origin\
        "${BASE}-cml-pr-${SHA}" &>/dev/null) ]]; then
  # branch already exists; just print its PR URL
  curl \
    -H "Accept: application/vnd.github.v3+json" \${GITHUB_REPOSITORY}/pulls \
    | jq -r ".[] | select(.head.ref == '${BASE}-cml-pr-${SHA}') | .url"
  # create branch & PR
  git checkout -b "${BASE}-cml-pr-${SHA}"
  git add "**/*.py" "**/*.json"
  git commit -m "CML PR for ${SHA} [skip ci]"
  git push
  curl \
    -X POST \
    -H "Accept: application/vnd.github.v3+json" \${GITHUB_REPOSITORY}/pulls \
    -d "{
      \"head\": \"${BASE}-cml-pr-${SHA}\",
      \"base\": \"${BASE}\",
      \"title\": \"CML PR for ${BASE} ${SHA}\",
        \"Automated commits for\
          ${GITHUB_REPOSITORY}/commit/${SHA} created by CML.\"
    }" \
    | jq -r .url

🐛 Found an issue? Let us know! Or fix it:

Edit on GitHub

Have a question? Join our chat, we will help you:

Discord Chat