Skip to main content

Cross-platform automated back-merge bot (Bitbucket / GitHub) with AI-assisted conflict resolution

Project description

lcdp-back-merge

Bot de back-merge automatique multi-plateforme (Bitbucket Cloud / GitHub) avec résolution IA des conflits.

Quoi ça fait

Pour chaque branche divergente de la branche source courante :

  1. Crée une branche auto-merge/<source>-into-<target>
  2. Tente le merge ; si conflit, demande à Claude une proposition de résolution par fichier
  3. Ouvre une PR avec une description riche (statut, fichiers en conflit, suggestions IA)
  4. Auto-merge si pas de conflit OU si l'IA a résolu tous les fichiers avec confiance high
  5. Notifie Slack sinon (review requise)

Configuration

Variables d'environnement requises

Variable Plateforme Description
BB_AUTH_STRING Bitbucket client_id:client_secret OAuth pour l'API Bitbucket
GITHUB_APP_ID GitHub App ID du GitHub App (auth App uniquement, pas de PAT)
GITHUB_APP_PRIVATE_KEY GitHub Clé privée PEM du GitHub App. Permissions requises : contents:write + pull-requests:write

La plateforme est détectée automatiquement via les variables CI standard (BITBUCKET_BRANCH, GITHUB_ACTIONS).

GitHub : l'auth se fait exclusivement via GitHub App (le script génère lui-même un installation token court). L'App doit être installée sur le repo cible.

Variables d'environnement optionnelles

Variable Défaut Description
ANTHROPIC_API_KEY Active la résolution IA des conflits
ANTHROPIC_MODEL claude-sonnet-4-6 Modèle Claude utilisé pour la résolution
SLACK_WEBHOOK_URL Active les notifications Slack
AUTO_MERGE_TARGET_PATTERNS (toutes) Globs séparés par virgule : develop,release/*
AUTO_MERGE_BRANCH_MAP Mapping source→patterns : master:develop;develop:feature/*
AUTO_MERGE_DEFAULT_REVIEWERS Reviewers fallback en CSV (UUIDs Bitbucket ou logins GitHub)
AUTO_MERGE_PR_RUN_LIMIT -1 (illimité) Nombre max de PR créées par run

Utilisation en pipeline

Bitbucket Pipelines

branches:
  "{master}":
    - step:
        name: Back merge
        # image uv officielle (debian bookworm) → uv + git déjà présents
        image: ghcr.io/astral-sh/uv:python3.11-bookworm
        clone:
          depth: full          # toutes les branches divergentes
        script:
          - export AUTO_MERGE_TARGET_PATTERNS="develop"
          - uvx lcdp-back-merge
        # Variables (repository/deployment) : BB_AUTH_STRING, ANTHROPIC_API_KEY, SLACK_WEBHOOK_URL

GitHub Actions

- uses: actions/checkout@v4
  with:
    fetch-depth: 0          # toutes les branches divergentes
    persist-credentials: false   # le script gère l'auth git via le token App
- uses: astral-sh/setup-uv@v5
- name: Back-merge
  run: uvx lcdp-back-merge
  env:
    # Noms des secrets GitHub explicites (à gauche = ce que lit le script,
    # à droite = le secret/variable côté repo, nommé sans ambiguïté).
    GITHUB_APP_ID: ${{ vars.LCDP_BACKMERGE_APP_ID }}
    GITHUB_APP_PRIVATE_KEY: ${{ secrets.LCDP_BACKMERGE_APP_PRIVATE_KEY }}
    ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
    SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

Architecture

lcdp_back_merge/
├── cli.py              # argparse, entry point
├── runner.py           # boucle principale, orchestration
├── ai_resolver.py      # résolution de conflits via Claude
├── slack.py            # notifications Slack
├── git_utils.py        # wrappers subprocess git
└── platforms/
    ├── base.py         # abstract Platform
    ├── bitbucket.py    # adaptateur Bitbucket Cloud
    └── github.py       # adaptateur GitHub

Ajouter une plateforme = ajouter une sous-classe de Platform dans platforms/, l'enregistrer dans platforms.__init__.detect_platform().

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lcdp_back_merge-1.0.1.tar.gz (19.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lcdp_back_merge-1.0.1-py3-none-any.whl (24.1 kB view details)

Uploaded Python 3

File details

Details for the file lcdp_back_merge-1.0.1.tar.gz.

File metadata

  • Download URL: lcdp_back_merge-1.0.1.tar.gz
  • Upload date:
  • Size: 19.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.3 Linux/6.1.79

File hashes

Hashes for lcdp_back_merge-1.0.1.tar.gz
Algorithm Hash digest
SHA256 18e069df05689e012b9535a485e28a150dc3f830fb33efbce89d284e6f3bbfcf
MD5 b88bffcc5558b29e34f25fcc7dffa9bc
BLAKE2b-256 e890f72c67ac0780c612309c541c2408819314c4608e54624f5b3aa34ee66d59

See more details on using hashes here.

File details

Details for the file lcdp_back_merge-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: lcdp_back_merge-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 24.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.3 Linux/6.1.79

File hashes

Hashes for lcdp_back_merge-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 274023b8eea90ec3d5bd4f08f34ed1e5310b539a5e7b6eded1ae3bbccf58135b
MD5 47a10e1c66610ad3c28e81d2dba5d642
BLAKE2b-256 1be2fed4fc808b3e95574d0f47fe5d155c0e376aef7816566dc77df33e637ad0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page