def check_source()

in scripts/copy_druid_docs.py [0:0]


def check_source(source_directory):
    """
    Set source_directory to your OSS Druid repo.
    The default directory structure assumes apache/druid and apache/druid-website-src are peers.
    To pass in a non-default directory, use the --source flag or pass it into main()
    """

    is_valid = True
    error_msg = ""

    # Verify that the directory exists
    full_path_source = os.path.abspath(source_directory)
    print(f"\nChecking docs source from the following:\nRepo:\t'{full_path_source}'")
    if not os.path.exists(source_directory):
        is_valid = False
        error_msg = "Error: Supply a valid path for apache/druid in the '--source' flag"
        return is_valid, error_msg

    # Get the current branch of the source directory (apache/druid)
    branch_result = subprocess.run(["git", "rev-parse", "--abbrev-ref", "HEAD"], cwd=source_directory, capture_output=True)
    current_branch = branch_result.stdout.decode('ascii').strip()

    # Print information about the branch
    print(f"Branch:\t'{current_branch}'\n")

    # Verify source directory and its branch
    correct_branch = input("Is the listed docs source correct? (y/n) ").lower()
    if correct_branch == 'n':
        is_valid = False
        error_msg = "Error: Supply the correct repo for --source and check out the correct branch."

    return is_valid, error_msg