Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion examples/gemma-cookbook
Submodule gemma-cookbook deleted from 1cb7c8
37 changes: 37 additions & 0 deletions scripts/fix_conflicts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import sys, re, os

def resolve_markdown_list(content):
# More robust pattern to match git conflicts
pattern = re.compile(r'<<<<<<< .*?\n(.*?)\n?=======\n?(.*?)\n?>>>>>>>.*?(\n|$)', re.DOTALL)

Check warning on line 5 in scripts/fix_conflicts.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Fix this reluctant quantifier that will only ever match 0 repetitions.

See more on https://sonarcloud.io/project/issues?id=MasumRab_gemini-fullstack-langgraph-quickstart&issues=AZ202_IQ3BCkl1kCkdbU&open=AZ202_IQ3BCkl1kCkdbU&pullRequest=362

def replacement(match):
lines1 = match.group(1).split('\n') if match.group(1) else []
lines2 = match.group(2).split('\n') if match.group(2) else []

combined = []
seen = set()
for line in lines1 + lines2:
l = line.strip()
if l and line not in seen:
combined.append(line)
seen.add(line)
return '\n'.join(combined) + '\n'

return pattern.sub(replacement, content)

if __name__ == "__main__":
if len(sys.argv) < 2:
sys.exit(1)
path = sys.argv[1]
if os.path.isdir(path):
sys.exit(0)
if not os.path.exists(path):
sys.exit(0)
with open(path, 'r') as f:
try:
content = f.read()
except UnicodeDecodeError:
sys.exit(0)
resolved = resolve_markdown_list(content)
with open(path, 'w') as f:
Comment on lines +30 to +36

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (bug_risk): Using the default encoding for reading and writing might cause inconsistencies across environments.

Given this script processes Markdown, consider opening the file with an explicit encoding (e.g. encoding="utf-8" for both reads and writes, optionally with errors="ignore" or errors="replace"). This will avoid platform-dependent behavior and potential data corruption when system defaults differ.

Suggested implementation:

    with open(path, 'r', encoding='utf-8') as f:
    with open(path, 'w', encoding='utf-8') as f:

f.write(resolved)
Loading