Skip to content

Commit

Permalink
Improve relative order of import groups, and __all__, in git.index
Browse files Browse the repository at this point in the history
  • Loading branch information
EliahKagan committed Mar 18, 2024
1 parent 4badc19 commit 1c9bda2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 33 deletions.
5 changes: 3 additions & 2 deletions git/index/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
import sys
import tempfile

from gitdb.base import IStream
from gitdb.db import MemoryDB

from git.compat import defenc, force_bytes
import git.diff as git_diff
from git.exc import CheckoutError, GitCommandError, GitError, InvalidGitRepositoryError
Expand All @@ -33,8 +36,6 @@
unbare_repo,
to_bin_sha,
)
from gitdb.base import IStream
from gitdb.db import MemoryDB

from .fun import (
S_IFGITLINK,
Expand Down
41 changes: 16 additions & 25 deletions git/index/fun.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,28 @@
"""Standalone functions to accompany the index implementation and make it more
versatile."""

__all__ = (
"write_cache",
"read_cache",
"write_tree_from_cache",
"entry_key",
"stat_mode_to_index_mode",
"S_IFGITLINK",
"run_commit_hook",
"hook_path",
)

from io import BytesIO
import os
import os.path as osp
from pathlib import Path
from stat import (
S_IFDIR,
S_IFLNK,
S_ISLNK,
S_ISDIR,
S_IFMT,
S_IFREG,
S_IXUSR,
)
from stat import S_IFDIR, S_IFLNK, S_IFMT, S_IFREG, S_ISDIR, S_ISLNK, S_IXUSR
import subprocess
import sys

from gitdb.base import IStream
from gitdb.typ import str_tree_type

from git.cmd import handle_process_output, safer_popen
from git.compat import defenc, force_bytes, force_text, safe_decode
from git.exc import HookExecutionError, UnmergedEntriesError
Expand All @@ -29,8 +35,6 @@
tree_to_stream,
)
from git.util import IndexFileSHA1Writer, finalize_process
from gitdb.base import IStream
from gitdb.typ import str_tree_type

from .typ import BaseIndexEntry, IndexEntry, CE_NAMEMASK, CE_STAGESHIFT
from .util import pack, unpack
Expand All @@ -42,31 +46,18 @@
from git.types import PathLike

if TYPE_CHECKING:
from .base import IndexFile
from git.db import GitCmdObjectDB
from git.objects.tree import TreeCacheTup

# from git.objects.fun import EntryTupOrNone
from .base import IndexFile

# ------------------------------------------------------------------------------------


S_IFGITLINK = S_IFLNK | S_IFDIR
"""Flags for a submodule."""

CE_NAMEMASK_INV = ~CE_NAMEMASK

__all__ = (
"write_cache",
"read_cache",
"write_tree_from_cache",
"entry_key",
"stat_mode_to_index_mode",
"S_IFGITLINK",
"run_commit_hook",
"hook_path",
)


def hook_path(name: str, git_dir: PathLike) -> str:
""":return: path to the given named hook in the given git repository directory"""
Expand Down
3 changes: 2 additions & 1 deletion git/index/typ.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
from binascii import b2a_hex
from pathlib import Path

from .util import pack, unpack
from git.objects import Blob

from .util import pack, unpack

# typing ----------------------------------------------------------------------

from typing import NamedTuple, Sequence, TYPE_CHECKING, Tuple, Union, cast
Expand Down
7 changes: 2 additions & 5 deletions git/index/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

"""Index utilities."""

__all__ = ("TemporaryFileSwap", "post_clear_cache", "default_index", "git_working_dir")

import contextlib
from functools import wraps
import os
Expand All @@ -22,14 +24,9 @@

# ---------------------------------------------------------------------------------


__all__ = ("TemporaryFileSwap", "post_clear_cache", "default_index", "git_working_dir")

# { Aliases
pack = struct.pack
unpack = struct.unpack


# } END aliases


Expand Down

0 comments on commit 1c9bda2

Please sign in to comment.