Exemple #1
0
def sourcegit_and_remote(tmpdir):
    temp_dir = Path(str(tmpdir))

    sourcegit_remote = temp_dir / "source_git_remote"
    sourcegit_remote.mkdir()
    subprocess.check_call(["git", "init", "--bare", "."], cwd=sourcegit_remote)

    sourcegit_dir = temp_dir / "source_git"
    shutil.copytree(SOURCEGIT_UPSTREAM, sourcegit_dir)
    initiate_git_repo(sourcegit_dir, tag="0.1.0")
    subprocess.check_call(["cp", "-R", SOURCEGIT_SOURCEGIT, temp_dir],
                          cwd=sourcegit_remote)
    git_add_and_commit(directory=sourcegit_dir, message="sourcegit content")

    return sourcegit_dir, sourcegit_remote
Exemple #2
0
def upstream_instance_with_two_commits(upstream_instance):
    u, ups = upstream_instance
    new_file = u / "new.file"
    new_file.write_text("Some content")
    git_add_and_commit(u, message="Add new file")
    return u, ups
Exemple #3
0
def test_basic_local_update_patch_content(sourcegit_n_distgit,
                                          mock_remote_functionality_sourcegit,
                                          api_instance_source_git):
    """ propose-update for sourcegit test: mock remote API, use local upstream and dist-git """

    sourcegit, distgit = sourcegit_n_distgit

    source_file = sourcegit / "big-source-file.txt"
    source_file.write_text("new changes")
    git_add_and_commit(directory=sourcegit, message="source change")

    api_instance_source_git.sync_release("master",
                                         "0.1.0",
                                         upstream_ref="0.1.0")

    spec = get_specfile(str(distgit / "beer.spec"))

    spec_package_section = ""
    for section in spec.spec_content.sections:
        if "%package" in section[0]:
            spec_package_section += "\n".join(section[1])
    assert "Patch0001: 0001" in spec_package_section
    assert "Patch0002: 0002" not in spec_package_section  # no empty patches

    git_diff = subprocess.check_output(["git", "diff", "HEAD~", "HEAD"],
                                       cwd=distgit).decode()

    assert "-Version:        0.0.0\n+Version:        0.1.0" in git_diff
    assert "+# PATCHES FROM SOURCE GIT:" in git_diff
    assert (
        " - 0.1.0-1\n"
        "+- new upstream release: 0.1.0\n"
        "+\n"
        " * Sun Feb 24 2019 Tomas Tomecek <*****@*****.**> - 0.0.0-1\n"
        " - No brewing, yet.\n" in git_diff)

    # direct diff in the synced file
    assert ("diff --git a/.packit.yaml b/.packit.yaml\n"
            "new file mode 100644" in git_diff)
    assert "--- /dev/null\n" "+++ b/.packit.yaml" in git_diff

    # diff of the synced file should not be in the patch
    assert ("+diff --git a/.packit.yaml b/.packit.yaml\n"
            "+new file mode 100644\n" not in git_diff)

    # diff of the source file (not synced) has to be in the patch
    assert ("patch\n"
            "@@ -0,0 +1,9 @@\n"
            "+diff --git a/big-source-file.txt b/big-source-file.txt\n"
            in git_diff)

    assert ("+--- a/big-source-file.txt\n"
            "++++ b/big-source-file.txt\n"
            "+@@ -1,2 +1 @@\n"
            "+-This is a testing file\n"
            "+-containing some text.\n"
            "++new changes\n" in git_diff)

    # diff of the source files (not synced) should not be directly in the git diff
    assert ("--- a/big-source-file.txt\n"
            "+++ b/big-source-file.txt\n"
            "@@ -1,2 +1 @@\n"
            "-This is a testing file\n"
            "-containing some text.\n"
            "+new changes\n" not in git_diff)