-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from shaneknapp/fixing-some-bugs
resolving some issues/etc unearthed in the demo/walkthrough
- Loading branch information
Showing
6 changed files
with
114 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Lint and spell check | ||
on: | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.11" | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
# Update output format to enable automatic inline annotations. | ||
- name: Ruff Check | ||
run: ruff check --output-format=github . | ||
|
||
- uses: codespell-project/actions-codespell@v2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,30 @@ | ||
import argparse | ||
import re | ||
import sys | ||
|
||
from . import manage_repos | ||
|
||
|
||
def check_config(config): | ||
""" | ||
Check all entries in the config file to confirm they are in the proper | ||
format: | ||
[email protected]:<user or org>/<repo name>.git | ||
""" | ||
with open(config) as f: | ||
for line in f: | ||
line = line.strip() | ||
if not line or line.startswith("#"): | ||
continue | ||
|
||
if not re.match( | ||
"^[email protected]:[a-zA-Z0-9\.\-\_]+/[a-zA-Z0-9\.\-\_]+\.git$", line | ||
): | ||
print(f"Malformed entry in {config}: {line}. Exiting.") | ||
sys.exit(1) | ||
|
||
|
||
def main(): | ||
argparser = argparse.ArgumentParser() | ||
subparsers = argparser.add_subparsers( | ||
|
@@ -13,14 +36,15 @@ def main(): | |
"-c", | ||
"--config", | ||
default="repos.txt", | ||
help="Path to file containing list of repositories to operate on.", | ||
help="Path to the file containing list of repositories to operate on. " | ||
+ "Defaults to repos.txt located in the current working directory.", | ||
) | ||
argparser.add_argument( | ||
"-d", | ||
"--destination", | ||
default=".", | ||
help="Location on the filesystem of the managed repositories. If " | ||
+ "the directory does not exist, it will be created.", | ||
help="Location on the filesystem of the directory containing the " | ||
+ "managed repositories. Defaults to the current working directory.", | ||
) | ||
|
||
branch_parser = subparsers.add_parser( | ||
|
@@ -36,25 +60,21 @@ def main(): | |
clone_parser = subparsers.add_parser( | ||
"clone", | ||
description="Clone repositories in the config file and " | ||
+ "optionally set a remote for a fork.", | ||
+ "optionally set a remote for a fork. If a repository sub-directory " | ||
+ "does not exist, it will be created.", | ||
) | ||
clone_parser.add_argument( | ||
"-s", | ||
"--set-remote", | ||
action="store_true", | ||
help="Set the user's GitHub fork as a remote.", | ||
) | ||
clone_parser.add_argument( | ||
"-r", | ||
"--remote", | ||
default="origin", | ||
help="If --set-remote is used, override the name of the remote to " | ||
+ "set for the fork. This is optional and defaults to 'origin'.", | ||
const="origin", | ||
nargs="?", | ||
help="Set the user's GitHub fork as a remote. Defaults to 'origin'.", | ||
) | ||
clone_parser.add_argument( | ||
"-g", | ||
"--github-user", | ||
help="The GitHub username of the fork to set in the remote.", | ||
help="The GitHub username of the fork to set in the remote. Required " | ||
+ "if --set-remote is used.", | ||
) | ||
|
||
patch_parser = subparsers.add_parser( | ||
|
@@ -86,7 +106,8 @@ def main(): | |
"--files", | ||
nargs="+", | ||
default=["."], | ||
help="List of files to stage in the repositories.", | ||
help="Space-delimited list of files to stage in the repositories. " | ||
+ "Optional, and if left blank will default to all modified files.", | ||
) | ||
stage_parser.add_argument( | ||
"-m", | ||
|
@@ -128,8 +149,10 @@ def main(): | |
) | ||
|
||
args = argparser.parse_args() | ||
|
||
print(args) | ||
|
||
check_config(args.config) | ||
|
||
errors = [] | ||
if args.command == "branch": | ||
errors.append(manage_repos.branch(args)) | ||
|
@@ -147,8 +170,7 @@ def main(): | |
argparser.print_help() | ||
|
||
if any(errors): | ||
print("The following errors occurred during execution:") | ||
print(errors) | ||
print("\nThe following errors occurred during execution:") | ||
for error in errors: | ||
for e in error: | ||
print(e) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# these are currently only used for github actions and linting | ||
ruff==0.7.0 |