Update project files of AboutCode projects that use the skeleton This script will: - Clone the repo - Add the skeleton repo as a new origin - Create a new branch named "update-skeleton-files" - Merge in the new skeleton files into the "update-skeleton-files" branch The
(repo_names=ABOUTCODE_PUBLIC_REPO_NAMES)
| 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( |
| 91 | ["git", "remote", "add", "skeleton", "git@github.com:aboutcode-org/skeleton.git"] |
| 92 | ) |
| 93 | |
| 94 | # Fetch skeleton files |
| 95 | subprocess.run(["git", "fetch", "skeleton"]) |
| 96 | |
| 97 | # Create and checkout new branch |
| 98 | subprocess.run(["git", "checkout", "-b", "update-skeleton-files"]) |
| 99 | |
| 100 | # Merge skeleton files into the repo |
| 101 | subprocess.run(["git", "merge", "skeleton/main", "--allow-unrelated-histories"]) |
| 102 | |
| 103 | |
| 104 | if __name__ == "__main__": |
no test coverage detected