コード例 #1
0
def test_dependent_commit(env, git_gecko, git_wpt, pull_request,
                          upstream_wpt_commit, pull_request_commit):
    upstream_wpt_commit("First change", {"README": "Example change\n"})

    pr = pull_request([("Test change", {
        "README": "Example change 1\n"
    })], "Test PR")

    downstream.new_wpt_pr(git_gecko, git_wpt, pr)
    sync = load.get_pr_sync(git_gecko, git_wpt, pr["number"])

    assert len(sync.gecko_commits) == 2
    assert sync.gecko_commits[0].msg.splitlines()[0] == "First change"
    assert sync.gecko_commits[0].metadata["wpt-type"] == "dependency"
    assert sync.gecko_commits[1].metadata.get("wpt-type") is None
    assert "Test change" in sync.gecko_commits[1].msg.splitlines()[0]
    old_gecko_commits = sync.gecko_commits[:]
    # Check that rerunning doesn't affect anything
    sync.update_commits()
    assert [item.sha1 for item in sync.gecko_commits
            ] == [item.sha1 for item in old_gecko_commits]

    head_sha = pull_request_commit(pr.number, [("fixup! Test change", {
        "README": "Example change 2\n"
    })])
    downstream.update_repositories(git_gecko, git_wpt)
    sync.update_commits()
    assert len(sync.gecko_commits) == 3
    assert ([item.sha1 for item in sync.gecko_commits[:2]
             ] == [item.sha1 for item in old_gecko_commits])
    assert sync.gecko_commits[-1].metadata["wpt-commit"] == head_sha
コード例 #2
0
ファイル: test_downstream.py プロジェクト: dhdavvie/wpt-sync
def test_metadata_update(env, git_gecko, git_wpt, pull_request, pull_request_commit):
    from conftest import gecko_changes, git_commit
    pr = pull_request([("Test commit", {"README": "Example change\n"})],
                      "Test PR")

    downstream.new_wpt_pr(git_gecko, git_wpt, pr)
    sync = load.get_pr_sync(git_gecko, git_wpt, pr["number"])

    assert len(sync.gecko_commits) == 1

    with SyncLock.for_process(sync.process_name) as lock:
        with sync.as_mut(lock):
            gecko_work = sync.gecko_worktree.get()
            changes = gecko_changes(env, meta_changes={"example.ini": "Example change"})
            git_commit(gecko_work, """Update metadata

        wpt-pr: %s
        wpt-type: metadata
        """ % pr.number, changes)

            assert len(sync.gecko_commits) == 2
            assert sync.gecko_commits[-1].metadata.get("wpt-type") == "metadata"
            metadata_commit = sync.gecko_commits[-1]

            head_sha = pull_request_commit(pr.number,
                                           [("fixup! Test commit",
                                             {"README": "Example change 1\n"})])

            downstream.update_repositories(git_gecko, git_wpt)
            sync.update_commits()
            assert len(sync.gecko_commits) == 3
            assert sync.gecko_commits[-1].metadata.get("wpt-type") == "metadata"
            assert sync.gecko_commits[-1].msg == metadata_commit.msg
            assert sync.gecko_commits[-2].metadata.get("wpt-commit") == head_sha