Skip to content

Commit 0d7bc41

Browse files
committed
Fix diff detection logic
1 parent 042c04f commit 0d7bc41

File tree

3 files changed

+17
-62
lines changed

3 files changed

+17
-62
lines changed

.github/workflows/update-docs-alpha.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Deploy to Alpha Firestore
22

33
on:
44
push:
5-
branches: [ anusha/pinecone-github-action ]
5+
branches: [ main ]
66

77
jobs:
88
deploy-alpha:

docs_state_dev.json

Lines changed: 0 additions & 50 deletions
This file was deleted.

update_docs.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ def get_file_hash(file_path: str) -> Optional[str]:
4040
return None
4141

4242

43-
def get_git_changed_files() -> Tuple[List[str], List[str]]:
44-
"""Get changed files using Git diff."""
43+
def get_git_changed_files() -> Tuple[List[str], List[str], bool]:
44+
"""Get changed files using Git diff. Returns (changed_files, new_files, git_success)."""
4545
try:
4646
print("🔍 Comparing against base branch: origin/main")
4747

@@ -54,8 +54,8 @@ def get_git_changed_files() -> Tuple[List[str], List[str]]:
5454
)
5555

5656
if result.returncode != 0:
57-
print("⚠️ Could not get Git diff, processing all files")
58-
return [], []
57+
print("⚠️ Could not get Git diff")
58+
return [], [], False
5959

6060
changed_files = []
6161
for line in result.stdout.strip().split('\n'):
@@ -80,25 +80,30 @@ def get_git_changed_files() -> Tuple[List[str], List[str]]:
8080
if os.path.exists(full_path):
8181
new_files.append(full_path)
8282

83-
return changed_files, new_files
83+
return changed_files, new_files, True
8484

8585
except Exception as e:
8686
print(f"⚠️ Error using Git: {e}")
87-
return [], []
87+
return [], [], False
8888

8989

9090
def get_changed_files() -> Tuple[List[str], List[str], Dict[str, str]]:
9191
"""Detect which files have changed using Git."""
9292
print("🔍 Detecting changed files using Git...")
9393

94-
changed_files, new_files = get_git_changed_files()
94+
changed_files, new_files, git_success = get_git_changed_files()
9595

96-
# For first run or if Git fails, process all files
97-
if not changed_files and not new_files:
98-
print("🔄 No Git changes detected, processing all files...")
96+
# If Git diff failed, fall back to processing all files for safety
97+
if not git_success:
98+
print("🔄 Git diff failed - processing all files to ensure no changes are missed")
99+
print("⚠️ This is a safety fallback to prevent missing updates")
99100
all_files = _get_all_markdown_files()
100101
changed_files = all_files
101102
new_files = []
103+
# If Git succeeded but no markdown changes detected, return empty lists
104+
elif not changed_files and not new_files:
105+
print("✅ No markdown file changes detected, nothing to process")
106+
return [], [], {}
102107

103108
# Generate current hashes for all processed files
104109
current_hashes = {}
@@ -390,7 +395,7 @@ def incremental_update() -> None:
390395
changed_files, deleted_files, current_hashes = get_changed_files()
391396

392397
if not changed_files:
393-
print("✅ No changes detected. Index is up to date!")
398+
print("✅ No markdown file changes detected. Index is up to date!")
394399
return
395400

396401
# Clean up old records for changed files

0 commit comments

Comments
 (0)