コード例 #1
0
def get_github_permalink(clipboard_command: str) -> None:  # pragma: no cover
    # TODO: break this file up and stop ignoring coverage
    kcr = kak.KakouneCR(subprocess.run)
    kak_state = kak.get_state(kcr)
    git_root = kak_plugins_os.get_git_root(os.path.exists,
                                           kak_state.buffer_path)
    repo = git_api.RepoApi(git.Repo(git_root))
    relative_path = os.path.relpath(kak_state.buffer_path, git_root)
    permalink = repo.get_permalink(relative_path, kak_state)
    clipboard_job = clipboard.ClipboardJob(clipboard_command, permalink)
    clipboard.write_to_clipboard(subprocess.run, clipboard_job)
コード例 #2
0
def test_get_permalink():
    repo = git.RepoApi(
        FakeRepo(
            remote_url="[email protected]:abstractlyZach/kak_plugins.git",
            active_branch="newbranch",
        )
    )
    kak_state = fakes.FakeKakState(selection=fakes.FakeSelectionDescription("L9"))
    expected = (
        "https://github.com/abstractlyZach/kak_plugins/blob/newbranch/Makefile#L9"
    )
    assert repo.get_permalink("Makefile", kak_state) == expected
コード例 #3
0
def test_remote_https_url():
    repo = git.RepoApi(
        FakeRepo(remote_url="https://github.com/abstractlyZach/kak_plugins.git")
    )
    assert repo.github_url == "https://github.com/abstractlyZach/kak_plugins"
コード例 #4
0
def test_current_branch():
    repo = git.RepoApi(FakeRepo(active_branch="mybranch"))
    assert repo.current_branch == "mybranch"
コード例 #5
0
def test_init():
    """Raises no exceptions"""
    git.RepoApi("abc")