예제 #1
0
def verify():
    cwd = os.getcwd()
    if cwd.endswith(PULL_SUFFIX):
        repo_name = cwd[: -len(PULL_SUFFIX)]
        pull_repo_name = cwd
    else:
        repo_name = cwd
        pull_repo_name = cwd + PULL_SUFFIX

    os.chdir(repo_name)
    remote_commit_messages = utils.git_log_oneline_remote()
    main_commit_messages = utils.git_log_oneline()

    os.chdir(pull_repo_name)
    pull_commit_messages = utils.git_log_oneline()

    payload = {
        "git status --porcelain": utils.git_status(),
        "git branch": utils.git_branch(),
        "git log --oneline origin/master": remote_commit_messages,
        "main:git log --oneline": main_commit_messages,
        "pull:git log --oneline": pull_commit_messages,
        "pull_repo_name": pull_repo_name,
        "expect_msg": COMMIT_MSG,
    }
    client.verify("push_and_pull", payload)
예제 #2
0
def verify():
    commit_messages = utils.git_log_oneline()
    codefile = pathlib.Path(FILE_NAME)
    code = codefile.read_text()

    payload = {
        "git status --porcelain": utils.git_status(),
        "git branch": utils.git_branch(),
        "git log --oneline": commit_messages,
        "code": code,
    }
    client.verify("amend", payload)
예제 #3
0
def verify():
    payload = {
        "git status --porcelain":
        utils.git_status(),
        "git branch":
        utils.git_branch(),
        "git rev-list --left-right --count master...origin/master":
        utils.rev_list_count_remote("master"),
        "git log -1 --oneline":
        utils.git_log_last_oneline(),
    }

    client.verify("my_first_commit", payload)
예제 #4
0
파일: revert.py 프로젝트: git-scientist/gsc
def verify():
    commit_messages = utils.git_log_oneline()
    codefile = pathlib.Path(FILE_NAME)
    code = codefile.read_text()

    payload = {
        "git status --porcelain": utils.git_status(),
        "git branch": utils.git_branch(),
        "git log --oneline": commit_messages,
        "git log -1 --pretty=%B": utils.git_log_last_pretty(),
        "code": code,
        "revert_hash": REVERT_HASH,
    }
    client.verify("revert", payload)
예제 #5
0
def verify():
    state = json.loads(pathlib.Path(".gsc_state").read_text())
    commit_hashes = utils.git_log_hashes()
    commit_messages = utils.git_log_oneline()

    payload = {
        "git status --porcelain": utils.git_status(),
        "git branch": utils.git_branch(),
        "git rev-list --left-right --count master...origin/master": utils.rev_list_count_remote(
            "master"
        ),
        "state": state,
        "git log --format=%H": commit_hashes,
        "git log --oneline": commit_messages,
        "remote_commit_message": REMOTE_COMMIT_MSG,
        "local_commit_message": LOCAL_COMMIT_MSG,
    }
    client.verify("sync_error", payload)
예제 #6
0
def verify():
    # TODO: this should be sorted out properly.
    # We can run git log on the correct branch.
    # We can check out the file from the correct branch as long as we back it up and restore it
    # after.
    # Then we won't need to change branch.
    # If we're still in the middle of the merge conflict we won't be able to change branch
    if utils.mid_rebase():
        raise verifier.VerifyError(
            "You haven't finished rebasing yet. Run `git status` to see what to do next."
        )

    state = json.loads(pathlib.Path(".gsc_state").read_text())

    # We should have the branch
    res = subprocess.run(["git", "checkout", BRANCH_NAME],
                         stdout=PIPE,
                         stderr=PIPE)
    if res.returncode != 0:
        raise verifier.VerifyError(
            f'The "{BRANCH_NAME}" branch has been deleted!\n'
            "Run `gsc reset` to start again.")

    commit_hashes = utils.git_log_hashes()
    commit_messages = utils.git_log_oneline()

    codefile = pathlib.Path(FILE_NAME)
    code = codefile.read_text()

    payload = {
        "git status --porcelain": utils.git_status(),
        "git branch": utils.git_branch(),
        "branch_name": BRANCH_NAME,
        "state": state,
        "git log --format=%H": commit_hashes,
        "git log --oneline": commit_messages,
        "master_commit_message": MASTER_COMMIT_MSG,
        "branch_commit_message": BRANCH_COMMIT_MSG,
        "code": code,
    }
    client.verify("merge_conflict", payload)
예제 #7
0
def verify():
    try:
        state = json.loads(pathlib.Path(".gsc_state").read_text())
    except FileNotFoundError:
        raise verifier.VerifyError(
            "You haven't set up the exercise.\nRun `gsc setup`.")

    commit_messages = utils.git_log_oneline()

    # The code should be the same as in the initial commit
    codefile = pathlib.Path(FILE_NAME)
    code = codefile.read_text()

    payload = {
        "git status --porcelain": utils.git_status(),
        "git branch": utils.git_branch(),
        "git log --oneline": commit_messages,
        "state": state,
        "code": code,
    }
    client.verify("reset_file", payload)
예제 #8
0
def verify():
    # TODO: this should be sorted out properly.
    # See merge_conflict.py
    if utils.mid_rebase():
        raise verifier.VerifyError(
            "You haven't finished rebasing yet. Run `git status` to see what to do next."
        )
    state = json.loads(pathlib.Path(".gsc_state").read_text())

    # We should have the branch
    res = subprocess.run(["git", "checkout", BRANCH_NAME], stdout=PIPE, stderr=PIPE)
    if res.returncode != 0:
        raise verifier.VerifyError(
            f'The "{BRANCH_NAME}" branch has been deleted!\n'
            "Run `gsc reset` to start again."
        )

    commit_hashes = utils.git_log_hashes()
    commit_messages = utils.git_log_oneline()

    codefile = pathlib.Path(FILE_NAME)
    code = codefile.read_text()

    payload = {
        "git status --porcelain": utils.git_status(),
        "git branch": utils.git_branch(),
        "git rev-list --left-right --count": utils.rev_list_count_remote(BRANCH_NAME),
        "branch_name": BRANCH_NAME,
        "state": state,
        "git log --format=%H": commit_hashes,
        "git log --oneline": commit_messages,
        "master_commit_message": MASTER_COMMIT_MSG,
        "branch_commit_message": BRANCH_COMMIT_MSG,
        "code": code,
    }
    client.verify("use_the_force", payload)