auto-mr

command module
v0.16.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2026 License: MIT Imports: 19 Imported by: 0

README

auto-mr

A Go-based automated merge request tool for GitLab, GitHub, and self-hosted Forgejo repositories. Platform APIs, git authentication and interactive prompts all use native Go libraries, so the only external command required is git itself.

Features

  • ✅ No platform CLIs required (replaces glab, gh, jq, yq, gum); only git itself is needed
  • ✅ Support for GitLab, GitHub, and self-hosted Forgejo
  • ✅ Interactive label selection
  • ✅ Pipeline/workflow waiting with timeout
  • ✅ Auto-approval and merging
  • ✅ Branch cleanup after merge
  • ✅ Configuration via YAML file

Installation

From Releases
  • Download the latest release from the releases page.
  • Install the binary in /usr/local/bin or any other directory in your PATH.
With go
go install github.com/sgaunet/auto-mr@latest
From source:
git clone https://github.com/sgaunet/auto-mr
cd auto-mr
go build -o auto-mr
Homebrew
brew tap sgaunet/homebrew-tools
brew install sgaunet/tools/auto-mr

Configuration

Create a configuration file at ~/.config/auto-mr/config.yml:

gitlab:
  assignee: your-gitlab-username
  reviewer: reviewer-gitlab-username
github:
  assignee: your-github-username
  reviewer: reviewer-github-username
forgejo:
  url: https://forgejo.example.com   # required: your self-hosted Forgejo instance URL
  assignee: your-forgejo-username
  reviewer: reviewer-forgejo-username

The forgejo section is only required when working with a Forgejo repository. The instance URL (url) is mandatory because Forgejo is self-hosted — there is no default host. Platform detection matches the git remote host against the configured forgejo.url.

Environment Variables

GitLab

Set your GitLab personal access token:

export GITLAB_TOKEN="your-gitlab-token"
GitHub

Set your GitHub personal access token:

export GITHUB_TOKEN="your-github-token"
Forgejo

Set your Forgejo personal access token:

export FORGEJO_TOKEN="your-forgejo-token"

Usage

  1. Make sure you're on a feature branch (not main/master)
  2. Commit and ensure there are no staged changes
  3. Run the tool:
auto-mr
Options
  • --squash: Squash commits when merging (default: false, preserves commit history)
  • --log-level: Set log level (debug, info, warn, error) (default: "info")
  • --version: Print version and exit

Example with squash:

auto-mr --squash
Workflow

The tool will:

  1. Detect if you're using GitLab, GitHub, or Forgejo
  2. Push your current branch
  3. Let you select labels interactively
  4. Create a merge/pull request with proper assignee and reviewer
  5. Wait for CI/CD pipeline completion
  6. Auto-approve (GitLab only; Forgejo and GitHub skip this step) and merge the request (squash if --squash flag is used)
  7. Switch back to main branch and clean up

Replaced Dependencies

This Go version eliminates these external dependencies:

Original Tool Replaced With
glab GitLab Go client library
gh GitHub Go client library
jq Native Go JSON processing
yq Native Go YAML processing
gum Survey library for interactive prompts
git go-git library for push and authentication; the git command is still used for cleanup, branch detection, and as a push fallback

Token Permissions

GitLab Token Permissions
  • api (full API access)
  • read_repository
  • write_repository
GitHub Token Permissions
  • repo (full repository access)
  • workflow (if using GitHub Actions)
Forgejo Token Permissions
  • repository (read and write access to repositories)
  • issue (read and write access — required to manage pull requests)

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run tests: go test ./...
  5. Submit a pull request

License

MIT License - see LICENSE file for details.

Documentation

Overview

Package main provides the entry point for the auto-mr CLI tool.

Directories

Path Synopsis
internal
labels
Package labels provides automatic label selection based on conventional commit types.
Package labels provides automatic label selection based on conventional commit types.
logger
Package logger provides logging utilities for auto-mr using the bullets library.
Package logger provides logging utilities for auto-mr using the bullets library.
polling
Package polling provides the timing primitives shared by the GitLab, GitHub and Forgejo CI pollers: a bound for a single API request, and a wait that a context can interrupt.
Package polling provides the timing primitives shared by the GitLab, GitHub and Forgejo CI pollers: a bound for a single API request, and a wait that a context can interrupt.
security
Package security provides token security and credential sanitization utilities to prevent accidental leakage of sensitive data in logs and error messages.
Package security provides token security and credential sanitization utilities to prevent accidental leakage of sensitive data in logs and error messages.
timeutil
Package timeutil provides time formatting utilities for human-readable duration display.
Package timeutil provides time formatting utilities for human-readable duration display.
trackmap
Package trackmap provides a small mutex-guarded map for the CI trackers.
Package trackmap provides a small mutex-guarded map for the CI trackers.
urlutil
Package urlutil provides URL parsing utilities for git remote URLs: extracting path components with ExtractPathComponents and the bare hostname with Host.
Package urlutil provides URL parsing utilities for git remote URLs: extracting path components with ExtractPathComponents and the bare hostname with Host.
pkg
commits
Package commits provides commit history retrieval and message selection for merge/pull requests.
Package commits provides commit history retrieval and message selection for merge/pull requests.
config
Package config handles loading and validation of user configuration from ~/.config/auto-mr/config.yml.
Package config handles loading and validation of user configuration from ~/.config/auto-mr/config.yml.
forgejo
Package forgejo provides a Forgejo API client for pull request lifecycle management.
Package forgejo provides a Forgejo API client for pull request lifecycle management.
git
Package git provides git repository operations for auto-mr.
Package git provides git repository operations for auto-mr.
github
Package github provides a GitHub API client for pull request lifecycle management.
Package github provides a GitHub API client for pull request lifecycle management.
gitlab
Package gitlab provides a GitLab API client for merge request lifecycle management.
Package gitlab provides a GitLab API client for merge request lifecycle management.
platform
Package platform provides a unified abstraction layer for GitLab and GitHub operations.
Package platform provides a unified abstraction layer for GitLab and GitHub operations.
testing
fixtures
Package fixtures provides common test data structures for testing.
Package fixtures provides common test data structures for testing.
mocks
Package mocks provides mock implementations for testing.
Package mocks provides mock implementations for testing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL