Skip to content

Commit 0f963e5

Browse files
committed
Added repo sync to repo to keep public and private repos in sync
1 parent a625a44 commit 0f963e5

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

repo_sync.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import subprocess
2+
import os
3+
import shutil
4+
5+
# Use a local path for testing
6+
# source_repo = "/Users/alexander.neben/workspace/mongo4"
7+
# destination_repo = "/Users/alexander.neben/workspace/mongo3"
8+
9+
source_repo = "[email protected]:10gen/docs-mongodb-internal.git"
10+
destination_repo = "[email protected]:mongodb/docs.git"
11+
branches_to_sync = ["master", "v7.0", "v6.0"] # TODO: add all branches you want to sync
12+
13+
# TODO: deal with creds
14+
15+
# Delete folder if it was there
16+
shutil.rmtree("docs-mongodb-internal", ignore_errors=True)
17+
18+
# Clone the repo
19+
# TODO: if run in evergreen this might need to be changed to a fetch
20+
subprocess.run(["git", "clone", source_repo, "docs-mongodb-internal"], check=True)
21+
22+
# cd into new cloned directory
23+
os.chdir("docs-mongodb-internal")
24+
25+
# Add the destination repo and name it upstream
26+
subprocess.run(["git", "remote", "add", "upstream", destination_repo], check=True)
27+
28+
for branch in branches_to_sync:
29+
subprocess.run(["git", "checkout", branch], check=True)
30+
subprocess.run(["git", "push", "upstream", branch], check=True)

0 commit comments

Comments
 (0)