Skip to content

Commit

Permalink
Fixed bug where non-root located project files weren't being processed
Browse files Browse the repository at this point in the history
  • Loading branch information
dragos240 committed Jan 12, 2025
1 parent d9a3be3 commit 3edcd09
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions common.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from nt import listdir
import time
import os
import subprocess
Expand Down Expand Up @@ -65,7 +66,14 @@ def check_repo_exists() -> bool:

def get_work_dir():
"""Gets work directory"""
return os.path.split(bpy.data.filepath)[0]
path = os.path.split(bpy.data.filepath)[0]
for _ in range(3):
for file in listdir(path):
if file.startswith(".git"):
return path
path = os.path.join(path, "..")

raise Exception()


def needs_refresh(refresh_type: str) -> bool:
Expand Down Expand Up @@ -155,13 +163,15 @@ def get_statuses_from_code(code: str) -> Tuple[str, str]:
return (staged_status, working_status)

def parse_line(line: str) -> Dict:
parts = [line[:2], line.split()[-1]]
print(1, line)
parts = [line[:2], " ".join(line[2:].split())]
print(2, parts) # FIXME
staged_status, working_status = get_statuses_from_code(parts[0])
entry = {
"status": (staged_status
if staged_status.rstrip()
else working_status),
"file_path": parts[-1],
"file_path": parts[1].replace('"', ''),
"staged": (True
if (staged_status.rstrip())
else False)
Expand Down Expand Up @@ -189,6 +199,7 @@ def do_git(*args) -> str:
args = [str(arg) for arg in args]
# We need to make this into a string since shell==True
cmd = "git " + " ".join(args)
print(cmd)

try:
result = subprocess.run(
Expand Down

0 comments on commit 3edcd09

Please sign in to comment.