Automate the sync of in-house forks with upstream repositories

オープン
#1,240 コメント 1 件 リアクション 2 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
bash, git, typescript
領域
devops, security

調査の方向性

プロジェクトファイルやテストは指定されていません。リクエストで説明されている repository-page と scheduler のエントリーポイントから始め、動作のリファレンスとして例示されている sync-upstream.sh のフローを使用してください。管理者が保護された認証情報とスケジュールを使用して複数の Branch 同期ジョブを設定し、ステータスを確認し、upstream-to-target の同期を実行できれば完了です。

索引モデルが issue の本文から書いたものです。

説明

feature

Is your feature request related to a problem? Please describe.
We find ourselves creating internal forks/replicas of upstream repositories that are used for internal collaboration prior to contribution or to support consumption of a repository or testing of code under review. These repositories have to be synchronised (changes pulled and merged) with their upstream counterparts - often the main or default branch, but sometimes other branches as well. That synchronisation can be performed manually or scripted, but it would be more convenient for our users if the repositories were automatically synced (on a schedule or on activity upstream).

Using Git Proxy to automate the synchronisation would also allow us to apply a plugin chain to change sets as they ingress to generate notifications or block sync if issues are detected (such as unexpected obfuscated code).

Describe the solution you'd like
Git Proxy could support an admin feature to synchronise nominated branches from an upstream repository with another git repository. This would require:

  • An administrative interface to configure syncing
    • Update the repository page to configure syncing for a git proxy project
      • Allow config of multiple sync jobs per project
      • Allow selection of a branch to sync and entry of target repository URL, username and access token
        • Access tokens should be encrypted at rest
        • We may also need to support the config of credentials for the upstream repo to support private projects
      • Allow configuration of a schedule for each sync job
    • View all sync jobs and status
      • Link to the relevant repo page for editing scheduled jobs
  • A scheduler to execute the sync tasks according to their schedules.

In addition to enabling that synchronisation, being able to apply a plugin chain to the changes to be synchronized and then blocking the sync and/or sending a notification would be highly desirable.

Describe alternatives you've considered
A manually maintained set of sync jobs implemented and managed via shell scripts, which must be run somewhere.

Additional context

A sync job could be implemented in bash (for illustrative purposes) as below - the proposal is to have git proxy handle this, with web-based admin and the isometric git client instead:

#!/bin/bash

# === Usage ===
# ./sync-upstream.sh <target_repo_url> <target_branch> <upstream_repo_url> <upstream_branch>

# === Arguments ===
TARGET_REPO_URL="$1"
TARGET_REPO_BRANCH="$2"
UPSTREAM_REPO_URL="$3"
UPSTREAM_BRANCH="$4"

# === Derive repo name from target URL ===
TARGET_REPO_NAME=$(basename "$TARGET_REPO_URL" .git)

# === Derived Variables ===
TEMP_DIR="/tmp/git-sync-$TARGET_REPO_NAME"

# === Prepare working directory ===
mkdir -p "$TEMP_DIR"
cd "$TEMP_DIR" || exit 1

# === Clone target repo ===
git clone "$TARGET_REPO_URL"
cd "$TARGET_REPO_NAME" || exit 1

# === Switch to target branch ===
git switch "$TARGET_REPO_BRANCH"

# === Add upstream remote and fetch ===
git remote add upstream "$UPSTREAM_REPO_URL"
git fetch upstream

# === Check for upstream changes not in target ===
CHANGES=$(git rev-list HEAD..upstream/$UPSTREAM_BRANCH --count)

if [ "$CHANGES" -eq 0 ]; then
    echo "No changes to sync from upstream/$UPSTREAM_BRANCH. Exiting."
    cd ..
    rm -rf "$TARGET_REPO_NAME"
    exit 0
else
    echo "Found $CHANGES new commits in upstream/$UPSTREAM_BRANCH. Proceeding with sync..."
fi

# === Merge and push ===
git merge --no-edit upstream/"$UPSTREAM_BRANCH"
git push

# === Cleanup ===
cd ..
rm -rf "$TARGET_REPO_NAME"

Example usage:


./sync-upstream.sh \
  https://scmprovider.com/your-org/git-proxy.git \
  main \
  https://github.com/finos/git-proxy.git \
  main

./sync-upstream.sh \
  https://scmprovider.com/your-org/fdc3.git \
  main \
  https://github.com/finos/fdc3.git \
  main

The feature could optionally allow the checked out dir to remain cached and not be removed/re-checked out. However, there may be security issue to consider.

主要言語
TypeScript
スター
263
フォーク
185
平均マージ
2日 15時間
マージ済み PR(30日)
39

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

finos/git-proxy のほかの issue

finos/git-proxy の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。