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.0.tar.gz (19.4 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.0-py3-none-any.whl (23.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lcdp_back_merge-1.0.0.tar.gz
  • Upload date:
  • Size: 19.4 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.0.tar.gz
Algorithm Hash digest
SHA256 fb26b837b7f75c99834ad0f1a43b7bf5e56f893f5b294286052d0db1217ef83d
MD5 f9e241390907cb40379936713b2aa875
BLAKE2b-256 8b93fd0699b225cf75f94baa300dd6528e95ff95106a6de2e106b83a255c66fa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lcdp_back_merge-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 23.9 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 79461e781d0e95e1d1bff280d78218be2df792abfaae427271c135ed4fc18e2f
MD5 19a36bd7839b91dfafdf02bf43222108
BLAKE2b-256 2d89248b3cf73dff6792c62ba8f82f2791d51583d00cf8f6dc339671de7031fe

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