Skip to content

Commit

Permalink
Fix crash that occurs for git blame for older versions of git (#55)
Browse files Browse the repository at this point in the history
* Fix crash the occurs for  for older versions of usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           [--super-prefix=<path>] [--config-env=<name>=<envvar>]
           <command> [<args>]

These are common Git commands used in various situations:

start a working area (see also: git help tutorial)
   clone     Clone a repository into a new directory
   init      Create an empty Git repository or reinitialize an existing one

work on the current change (see also: git help everyday)
   add       Add file contents to the index
   mv        Move or rename a file, a directory, or a symlink
   restore   Restore working tree files
   rm        Remove files from the working tree and from the index

examine the history and state (see also: git help revisions)
   bisect    Use binary search to find the commit that introduced a bug
   diff      Show changes between commits, commit and working tree, etc
   grep      Print lines matching a pattern
   log       Show commit logs
   show      Show various types of objects
   status    Show the working tree status

grow, mark and tweak your common history
   branch    List, create, or delete branches
   commit    Record changes to the repository
   merge     Join two or more development histories together
   rebase    Reapply commits on top of another base tip
   reset     Reset current HEAD to the specified state
   switch    Switch branches
   tag       Create, list, delete or verify a tag object signed with GPG

collaborate (see also: git help workflows)
   fetch     Download objects and refs from another repository
   pull      Fetch from and integrate with another repository or a local branch
   push      Update remote refs along with associated objects

'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.
See 'git help git' for an overview of the system.

* Update version to 0.12.1
  • Loading branch information
rzuckerm authored Feb 6, 2023
1 parent 3a9ac93 commit b5caa63
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

MAJOR = 0
MINOR = 12
PATCH = 0
PATCH = 1

name = "subete"
version = f"{MAJOR}.{MINOR}"
Expand Down
10 changes: 10 additions & 0 deletions subete/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,13 @@ def _load_git_data(self) -> None:
and inject that data into the repo object. This was done for simplicity.
It seems like way more of a pain to try to pass the git data around.
"""

# Make sure .git-blame-ignore-revs exists for older versions of git and
# keep track of whether it existed before
blame_path = Path(f"{self._temp_dir.name}/.git-blame-ignore-revs")
blame_path_exists = blame_path.exists()
blame_path.touch()

for language in self:
language: LanguageCollection
for program in language:
Expand All @@ -278,6 +285,9 @@ def _load_git_data(self) -> None:
program._modified = max(times)
logger.info(f"Loaded git data into existing program ({program}): {program._created} - {program._modified} by {program._authors}")

# Delete .git-blame-ignore-revs if it did not exist before
if not blame_path_exists:
blame_path.unlink()

class LanguageCollection:
"""
Expand Down

0 comments on commit b5caa63

Please sign in to comment.