Skip to content

Commit

Permalink
Also clone and update git versions of testprogs and techdocs
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.code.sf.net/p/vice-emu/code/trunk@44671 379a1393-f5fb-40a0-bcee-ef074d9b53f7
  • Loading branch information
michaelcmartin committed Nov 10, 2023
1 parent 71d31c7 commit 56cf4b0
Showing 1 changed file with 40 additions and 16 deletions.
56 changes: 40 additions & 16 deletions vice/make_vice_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@
import subprocess
import sys

SVN_REMOTE_PATH = "svn://svn.code.sf.net/p/vice-emu/code"
MIRROR_PATH = None
SVN_REPO_PATH = None
GIT_TARGET_PATH = None

if len(sys.argv) < 2:
print(f"Usage: {sys.argv[0]} <SVN-MIRROR-DIR>")
Expand All @@ -42,13 +38,21 @@
print(f"{MIRROR_PATH} exists and is not a directory; aborting")
sys.exit(1)

SVN_REMOTE_PATH = "svn://svn.code.sf.net/p/vice-emu/code"
SVN_REPO_PATH = MIRROR_PATH + "/svn-mirror"
GIT_TARGET_PATH = MIRROR_PATH + "/vice-git"
GIT_TECHDOCS_PATH = MIRROR_PATH + "/techdocs-git"
GIT_TESTPROGS_PATH = MIRROR_PATH + "/testprogs-git"

if os.path.exists(GIT_TARGET_PATH):
if not os.path.isdir(GIT_TARGET_PATH + "/.git"):
print(f"Error: {GIT_TARGET_PATH} already exists, and it's not a Git repo")
sys.exit(1)
def check_git(target_path):
if os.path.exists(target_path):
if not os.path.isdir(target_path + "/.git"):
print(f"Error: {target_path} already exists, and it's not a Git repo")
sys.exit(1)

check_git(GIT_TARGET_PATH)
check_git(GIT_TECHDOCS_PATH)
check_git(GIT_TESTPROGS_PATH)

def find_program(prog):
proc = subprocess.run(['which', prog], capture_output=True)
Expand Down Expand Up @@ -121,11 +125,31 @@ def find_program(prog):
f.write(f"{x} = {authors[x]}\n")
f.close()

if os.path.exists(GIT_TARGET_PATH):
print(f"Updating git repo")
os.chdir(GIT_TARGET_PATH)
subprocess.run(['git', 'svn', 'fetch'], check=True)
subprocess.run(['git', 'merge', 'svn/trunk'], check=True)
else:
print(f"Creating git edition of SVN repo at {GIT_TARGET_PATH}")
subprocess.run(['git', 'svn', 'clone', repo_url, '--prefix=svn/', '--stdlayout', f'--rewrite-root={SVN_REMOTE_PATH}', '--authors-file', AUTHORS_LIST, GIT_TARGET_PATH], check=True)
def git_update(target_path, subrepo=None):
if os.path.exists(target_path):
if subrepo == None:
branchname = "VICE"
branch = "svn/trunk"
else:
branchname = subrepo[1:]
branch = "svn/git-svn"
print(f"Updating git repo \"{branchname}\"")
os.chdir(target_path)
subprocess.run(['git', 'svn', 'fetch'], check=True)
subprocess.run(['git', 'merge', branch], check=True)
else:
args = ['git', 'svn', 'clone']
if subrepo == None:
branchname = "VICE"
args += [repo_url, '--prefix=svn/', '--stdlayout']
else:
branchname = subrepo[1:]
args += [repo_url + subrepo, '--prefix=svn/']

print(f"Creating git edition of {branchname} at {target_path}")

subprocess.run(args + [f'--rewrite-root={SVN_REMOTE_PATH}', '--authors-file', AUTHORS_LIST, target_path], check=True)

git_update(GIT_TARGET_PATH)
git_update(GIT_TECHDOCS_PATH, '/techdocs')
git_update(GIT_TESTPROGS_PATH, '/testprogs')

0 comments on commit 56cf4b0

Please sign in to comment.