Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions scripts/sync_all_siblings.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@
SHARED_REPO_NAME = "mcp-server-shared"
LOCK_FILE = "shared.lock"

# The GitHub account the siblings live under. Its noreply address is the commit e-mail
# the portfolio uses, so sync commits carry it whatever the local git config says.
# The GitHub account the siblings live under. Sync commits are authored as the account and
# its noreply address, whatever the local git config says: the siblings are public, and a
# real name in a commit is as public as one in a file (a sibling's privacy scan checks both).
OWNER = "SDNick484"
COMMIT_EMAIL = f"{OWNER}@users.noreply.github.com"
SSH_REMOTE_BASE = f"git@github.com:{OWNER}"
Expand Down Expand Up @@ -470,13 +471,13 @@ def pr_body(info: SiblingInfo, new_commit: str, checks: str, paths: Sequence[str
)


def _commit_env(repo: Path) -> dict[str, str]:
env = {"GIT_AUTHOR_EMAIL": COMMIT_EMAIL, "GIT_COMMITTER_EMAIL": COMMIT_EMAIL}
try:
_git(repo, "config", "user.name")
except GitError:
env |= {"GIT_AUTHOR_NAME": OWNER, "GIT_COMMITTER_NAME": OWNER}
return env
def _commit_env() -> dict[str, str]:
return {
"GIT_AUTHOR_NAME": OWNER,
"GIT_AUTHOR_EMAIL": COMMIT_EMAIL,
"GIT_COMMITTER_NAME": OWNER,
"GIT_COMMITTER_EMAIL": COMMIT_EMAIL,
}


def release_sibling(
Expand Down Expand Up @@ -558,7 +559,7 @@ def row(status: str, ok: bool, commit: str | None = None) -> StatusRow:
subject = SYNC_SUBJECT_PREFIX + new[:7]
body = f"shared.lock: {info.short_commit} -> {new[:7]} (scripts/sync_shared.py --update)\n\n"
body += "\n".join(f"- {p}" for p in paths)
_git(sibling, "commit", "--quiet", "-m", subject, "-m", body, env=_commit_env(sibling))
_git(sibling, "commit", "--quiet", "-m", subject, "-m", body, env=_commit_env())
except GitError as exc:
if branch != default:
_git(sibling, "switch", "--quiet", default) # the uncommitted changes come along
Expand Down
5 changes: 3 additions & 2 deletions tests/test_sync_all_siblings.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ def test_update_pr_opens_a_pr_only_for_siblings_that_pass(tmp_path: Path, portfo
beta = make_git_sibling(tmp_path, "mcp-server-beta", "beta_mcp") # fails ruff check
make_git_sibling(tmp_path, "mcp-server-gamma", "gamma_mcp") # this sync's PR already open
delta = make_git_sibling(tmp_path, "mcp-server-delta", "delta_mcp") # someone's work in progress
git(alpha, "config", "user.name", "Real Name") # a developer's identity must not reach the commit
tools.failing["mcp-server-beta"] = "ruff check"
branch = f"sync-shared-{COMMIT_B[:7]}"
gh.open[("mcp-server-gamma", branch)] = "https://github.example/mcp-server-gamma/pull/7"
Expand All @@ -422,8 +423,8 @@ def test_update_pr_opens_a_pr_only_for_siblings_that_pass(tmp_path: Path, portfo
assert remote_branches(tmp_path, "mcp-server-alpha") == ["main", branch]
remote = tmp_path / "remotes" / "mcp-server-alpha.git"
assert (
git(remote, "log", "-1", "--format=%s|%ae", branch).strip()
== f"Sync shared to {COMMIT_B[:7]}|{mod.COMMIT_EMAIL}"
git(remote, "log", "-1", "--format=%s|%an|%ae|%cn|%ce", branch).strip()
== f"Sync shared to {COMMIT_B[:7]}|{mod.OWNER}|{mod.COMMIT_EMAIL}|{mod.OWNER}|{mod.COMMIT_EMAIL}"
)
assert git(remote, "log", "-1", "--format=%s", "main").strip() == "initial"
assert git(alpha, "branch", "--show-current").strip() == "main"
Expand Down
Loading