• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

cisagov / lineage / 14107360035

27 Mar 2025 01:06PM UTC coverage: 14.118%. First build
14107360035

push

github

mcdonnnj
Rename the core entrypoint function

Now that there is a command-line interface it makes sense to use
something more descriptive than "main" for the core logic entrypoint.

3 of 82 branches covered (3.66%)

Branch coverage included in aggregate %.

1 of 2 new or added lines in 2 files covered. (50.0%)

45 of 258 relevant lines covered (17.44%)

0.87 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/lineage/cli.py
1
"""lineage is a tool to update GitHub repositories from upstream sources.
2

3
Search GitHub for repositories to update based on their configured upstream
4
lineage.
5

6
Usage:
7
    lineage [--exclude-non-public] [--show-non-public] --access-token=TOKEN --actor=ACTOR --repo-query=QUERY --working-directory=DIRECTORY
8

9
Options:
10
    -h --help                      Show this message.
11
    -v --version                   Show the version.
12
    --access-token=TOKEN           The GitHub access token to use.
13
    --actor=ACTOR                  The name to use for the commits created when
14
                                   updating repositories.
15
    --exclude-non-public           Exclude non-public (`private` and `internal`)
16
                                   repositories from updating.
17
    --repo-query=QUERY             The query used to find repositories to check for
18
                                   updates.
19
    --show-non-public              Do not mask the names of non-public (`private` and
20
                                   `internal`) repositories in the logs.
21
    --working-directory=DIRECTORY  The directory to change to before checking
22
                                   repositories.
23
"""
24

25
# Standard Python Libraries
26
import os.path
×
27
import sys
×
28
from typing import Any, Union
×
29

30
# Third-Party Libraries
31
import docopt
×
32
from schema import And, Schema, SchemaError
×
33

34
from . import entrypoint
×
35
from ._version import __version__
×
36

37

38
def main() -> None:
×
39
    """Parse and verify command line arguments before calling the main entrypoint."""
40
    args: dict[str, Union[bool, str]] = docopt.docopt(__doc__, version=__version__)
×
41

42
    schema: Schema = Schema(
×
43
        {
44
            "--access-token": And(
45
                str,
46
                lambda s: len(s) == 40,
47
                error="Provided token does not match the expected format.",
48
            ),
49
            "--actor": And(
50
                str,
51
                lambda s: len(s) > 0,
52
                error="The actor value must be a non-empty string.",
53
            ),
54
            "--repo-query": And(
55
                str,
56
            ),
57
            "--working-directory": And(
58
                str,
59
                lambda d: os.path.exists(d),
60
                error="The target working directory must exist.",
61
            ),
62
            str: object,  # Don't care about other keys, if any
63
        }
64
    )
65

66
    try:
×
67
        validated_args: dict[str, Any] = schema.validate(args)
×
68
    except SchemaError as err:
×
69
        # Exit because one or more arguments were invalid
70
        print(err, file=sys.stderr)
×
71
        sys.exit(1)
×
72

NEW
73
    entrypoint.update_repos(
×
74
        validated_args["--access-token"],
75
        validated_args["--actor"],
76
        validated_args["--working-directory"],
77
        validated_args["--repo-query"],
78
        not validated_args["--exclude-non-public"],
79
        not validated_args["--show-non-public"],
80
    )
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc