derek-thomas HF staff commited on
Commit
c1815e2
1 Parent(s): 5a23388

Updating to filter only readme only changes

Browse files
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -90,8 +90,17 @@ async def community(payload: WebhookPayload, task_queue: BackgroundTasks):
90
  commit_files_url = f"""{payload.repo.url.api}/compare/{payload.updatedRefs[0].oldSha}..{payload.updatedRefs[0].newSha}?raw=true"""
91
  response_text = requests.get(commit_files_url, headers=build_hf_headers()).text
92
  logger.info(f"Git Compare URl: {commit_files_url}")
93
- if 'README.md' in response_text:
94
- response_content = "No task scheduled: its a README update."
 
 
 
 
 
 
 
 
 
95
  logger.info(response_content)
96
  return Response(response_content, status_code=status.HTTP_200_OK)
97
  except Exception as e:
 
90
  commit_files_url = f"""{payload.repo.url.api}/compare/{payload.updatedRefs[0].oldSha}..{payload.updatedRefs[0].newSha}?raw=true"""
91
  response_text = requests.get(commit_files_url, headers=build_hf_headers()).text
92
  logger.info(f"Git Compare URl: {commit_files_url}")
93
+
94
+ # Splitting the output into lines
95
+ file_lines = response_text.split('\n')
96
+
97
+ # Filtering the lines to find file changes
98
+ changed_files = [line.split('\t')[-1] for line in file_lines if line.strip()]
99
+ logger.info(f"Changed files: {changed_files}")
100
+
101
+ # Checking if only README.md has been changed
102
+ if all('README.md' in file for file in changed_files):
103
+ response_content = "No task scheduled: its a README only update."
104
  logger.info(response_content)
105
  return Response(response_content, status_code=status.HTTP_200_OK)
106
  except Exception as e: