Skip to content

Commit dc123f1

Browse files
authored
Merge pull request #95 from aboutcode-org/80-update-skeleton-script
Update skeleton script
2 parents a2ced96 + 136af39 commit dc123f1

File tree

1 file changed

+103
-0
lines changed

1 file changed

+103
-0
lines changed

etc/scripts/update_skeleton.py

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#!/usr/bin/env python
2+
#
3+
# Copyright (c) nexB Inc. AboutCode, and others. All rights reserved.
4+
# ScanCode is a trademark of nexB Inc.
5+
# SPDX-License-Identifier: Apache-2.0
6+
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
7+
# See https://github.com/aboutcode-org/skeleton for support or download.
8+
# See https://aboutcode.org for more information about nexB OSS projects.
9+
#
10+
11+
from pathlib import Path
12+
import os
13+
import subprocess
14+
15+
import click
16+
17+
18+
ABOUTCODE_PUBLIC_REPO_NAMES=[
19+
"aboutcode-toolkit",
20+
"ahocode",
21+
"bitcode",
22+
"clearcode-toolkit",
23+
"commoncode",
24+
"container-inspector",
25+
"debian-inspector",
26+
"deltacode",
27+
"elf-inspector",
28+
"extractcode",
29+
"fetchcode",
30+
"gemfileparser2",
31+
"gh-issue-sandbox",
32+
"go-inspector",
33+
"heritedcode",
34+
"license-expression",
35+
"license_copyright_pipeline",
36+
"nuget-inspector",
37+
"pip-requirements-parser",
38+
"plugincode",
39+
"purldb",
40+
"pygmars",
41+
"python-inspector",
42+
"sanexml",
43+
"saneyaml",
44+
"scancode-analyzer",
45+
"scancode-toolkit-contrib",
46+
"scancode-toolkit-reference-scans",
47+
"thirdparty-toolkit",
48+
"tracecode-toolkit",
49+
"tracecode-toolkit-strace",
50+
"turbo-spdx",
51+
"typecode",
52+
"univers",
53+
]
54+
55+
56+
@click.command()
57+
@click.help_option("-h", "--help")
58+
def update_skeleton_files(repo_names=ABOUTCODE_PUBLIC_REPO_NAMES):
59+
"""
60+
Update project files of AboutCode projects that use the skeleton
61+
62+
This script will:
63+
- Clone the repo
64+
- Add the skeleton repo as a new origin
65+
- Create a new branch named "update-skeleton-files"
66+
- Merge in the new skeleton files into the "update-skeleton-files" branch
67+
68+
The user will need to save merge commit messages that pop up when running
69+
this script in addition to resolving the merge conflicts on repos that have
70+
them.
71+
"""
72+
73+
# Create working directory
74+
work_dir_path = Path("/tmp/update_skeleton/")
75+
if not os.path.exists(work_dir_path):
76+
os.makedirs(work_dir_path, exist_ok=True)
77+
78+
for repo_name in repo_names:
79+
# Move to work directory
80+
os.chdir(work_dir_path)
81+
82+
# Clone repo
83+
repo_git = f"git@github.com:aboutcode-org/{repo_name}.git"
84+
subprocess.run(["git", "clone", repo_git])
85+
86+
# Go into cloned repo
87+
os.chdir(work_dir_path / repo_name)
88+
89+
# Add skeleton as an origin
90+
subprocess.run(["git", "remote", "add", "skeleton", "git@github.com:aboutcode-org/skeleton.git"])
91+
92+
# Fetch skeleton files
93+
subprocess.run(["git", "fetch", "skeleton"])
94+
95+
# Create and checkout new branch
96+
subprocess.run(["git", "checkout", "-b", "update-skeleton-files"])
97+
98+
# Merge skeleton files into the repo
99+
subprocess.run(["git", "merge", "skeleton/main", "--allow-unrelated-histories"])
100+
101+
102+
if __name__ == "__main__":
103+
update_skeleton_files()

0 commit comments

Comments
 (0)