Skip to content

Commit ecae6f4

Browse files
feat: avoid updating gist if content and title are unchanged
Check existing gist content before updating to prevent unnecessary revisions in gist history when content hasn't actually changed. - Fetch current gist content using GitHub API - Compare both content and title with new values - Skip update if identical and log message - Return boolean to indicate whether update occurred Fixes #8 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: aksh1618 <[email protected]>
1 parent 2cd3cba commit ecae6f4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

codestats_box.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,16 @@ def update_gist(title: str, content: str) -> bool:
212212
gist = Github(access_token).get_gist(gist_id)
213213
# Works only for single file. Should we clear all files and create new file?
214214
old_title = list(gist.files.keys())[0]
215+
216+
# Check if content has changed to avoid unnecessary updates
217+
current_content = gist.files[old_title].content
218+
if current_content == content and old_title == title:
219+
print(f"No changes detected. Skipping gist update.")
220+
return False
221+
215222
gist.edit(title, {old_title: InputFileContent(content, title)})
216223
print(f"{title}\n{content}")
224+
return True
217225

218226

219227
def get_stats() -> str:

0 commit comments

Comments
 (0)