serJD commited on
Commit
ae0554f
·
1 Parent(s): 9541170

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -2
app.py CHANGED
@@ -25,7 +25,10 @@ import json
25
  # dictionary that collects tags that can be added to commit messages.
26
  # key -> column name in notion
27
  # value -> possible values
28
- tag_dict = {"status_tag":["WIP", "ReviewNeeded", "Final"]}
 
 
 
29
 
30
  # tag part seperator -> #+ , other_tags
31
 
@@ -68,6 +71,12 @@ def extract_branch_info(stream_id, server_url=None, token=None):
68
  branch_data["commit_url"] = f"{server_url}streams/{stream_id}/commits/{latest_commit.id}"
69
  branch_data["commit_message"] = latest_commit.message
70
  branch_data["author"] = latest_commit.authorName
 
 
 
 
 
 
71
  #except Exception as e:
72
  # print(f"Error fetching commits for branch {branch.name}: {str(e)}")
73
 
@@ -166,6 +175,9 @@ def sync_to_notion(token, database_id, branch_data):
166
  updated_isoformat = updated_value.isoformat()
167
  else:
168
  updated_isoformat = datetime.datetime.now().isoformat() # Use datetime.datetime.now() here
 
 
 
169
 
170
  page_data = {
171
  "properties": {
@@ -178,7 +190,8 @@ def sync_to_notion(token, database_id, branch_data):
178
  "sub-variant": {"rich_text": [{"text": {"content": branch.get("sub-variant", "")}}]},
179
  "author": {"rich_text": [{"text": {"content": branch.get("author", "")}}]},
180
  "commit_message": {"rich_text": [{"text": {"content": branch.get("commit_message", "")}}]},
181
- "depends-on": {"multi_select": [{"name": d} for d in existing_depends_on]}
 
182
  }
183
  }
184
 
 
25
  # dictionary that collects tags that can be added to commit messages.
26
  # key -> column name in notion
27
  # value -> possible values
28
+ tag_dict = {"status-message":["WIP", "ReviewNeeded", "Final"]}
29
+
30
+
31
+
32
 
33
  # tag part seperator -> #+ , other_tags
34
 
 
71
  branch_data["commit_url"] = f"{server_url}streams/{stream_id}/commits/{latest_commit.id}"
72
  branch_data["commit_message"] = latest_commit.message
73
  branch_data["author"] = latest_commit.authorName
74
+ # Check if the commit message contains '#+' and then extract tags
75
+ if '#+' in latest_commit.message:
76
+ tags_part = latest_commit.message.split("#+")[1]
77
+ branch_data["status-message"] = [tg for tg in tag_dict["status-message"] if tg in tags_part]
78
+ else:
79
+ branch_data["status-message"] = []
80
  #except Exception as e:
81
  # print(f"Error fetching commits for branch {branch.name}: {str(e)}")
82
 
 
175
  updated_isoformat = updated_value.isoformat()
176
  else:
177
  updated_isoformat = datetime.datetime.now().isoformat() # Use datetime.datetime.now() here
178
+ # Prepare status-message tags for multi-select
179
+ status_messages = branch.get("status-message", [])
180
+ status_message_data = [{"name": sm} for sm in status_messages]
181
 
182
  page_data = {
183
  "properties": {
 
190
  "sub-variant": {"rich_text": [{"text": {"content": branch.get("sub-variant", "")}}]},
191
  "author": {"rich_text": [{"text": {"content": branch.get("author", "")}}]},
192
  "commit_message": {"rich_text": [{"text": {"content": branch.get("commit_message", "")}}]},
193
+ "depends-on": {"multi_select": [{"name": d} for d in existing_depends_on]},
194
+ "status-message": {"multi_select": status_message_data}
195
  }
196
  }
197