-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommit-msg
executable file
·140 lines (113 loc) · 3.67 KB
/
commit-msg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/usr/local/bin/python3
import sys
import os
from notion.client import NotionClient
from notion.block import PageBlock
from notion.block import TextBlock
from notion.block import ToggleBlock
from notion.markdown import markdown_to_notion
from datetime import datetime
import notion.records
from tzlocal import get_localzone
import notion
def call_load_page_chunk(self, page_id):
if self._client.in_transaction():
self._pages_to_refresh.append(page_id)
return
data = {
"pageId": page_id,
"limit": 100,
"cursor": {"stack": []},
"chunkNumber": 0,
"verticalColumns": False,
}
recordmap = self._client.post("loadPageChunk", data).json()["recordMap"]
self.store_recordmap(recordmap)
def call_query_collection(
self,
collection_id,
collection_view_id,
search="",
type="table",
aggregate=[],
aggregations=[],
filter={},
sort=[],
calendar_by="",
group_by="",
):
assert not (
aggregate and aggregations
), "Use only one of `aggregate` or `aggregations` (old vs new format)"
# convert singletons into lists if needed
if isinstance(aggregate, dict):
aggregate = [aggregate]
if isinstance(sort, dict):
sort = [sort]
data = {
"collectionId": collection_id,
"collectionViewId": collection_view_id,
"loader": {
"limit": 1000000,
"loadContentCover": True,
"searchQuery": search,
"userLocale": "en",
"userTimeZone": str(get_localzone()),
"type": type,
},
"query": {
"aggregate": aggregate,
"aggregations": aggregations,
"filter": filter,
"sort": sort,
},
}
response = self._client.post("queryCollection", data).json()
self.store_recordmap(response["recordMap"])
return response["result"]
def search_pages_with_parent(self, parent_id, search=""):
data = {
"query": search,
"parentId": parent_id,
"limit": 100,
"spaceId": self.current_space.id,
}
response = self.post("searchPagesWithParent", data).json()
self._store.store_recordmap(response["recordMap"])
return response["results"]
notion.store.RecordStore.call_load_page_chunk = call_load_page_chunk
notion.store.RecordStore.call_query_collection = call_query_collection
notion.client.NotionClient.search_pages_with_parent = search_pages_with_parent
# Build the content
fileThatContainsChanges = open(sys.argv[1], "r")
changes = fileThatContainsChanges.read().splitlines()
changesLength = len(changes)
now = datetime.now()
current_time = now.strftime("%H:%M:%S")
description = ""
for changeIndex in range(changesLength):
tempDesc = ""
if changeIndex == 0 or not changes[changeIndex]:
continue
if changes[changeIndex] and changes[changeIndex][0] == "*":
tempDesc = changes[changeIndex][:1] + " " + changes[changeIndex][1:] + '\r'
else:
tempDesc = changes[changeIndex] + '\n'
description = description + tempDesc
terminalStream = os.popen('git status -s')
fileschanged = terminalStream.read()
numberOfFilesChanged = len(fileschanged.splitlines())
# Notion Section
token_v2 = 'TOKEN'
client = NotionClient(token_v2=token_v2)
#Url of the commit table.
url = "URL"
cv = client.get_collection_view(url, force_refresh=True)
row = cv.collection.add_row()
row.title = changes[0]
row.description = description
row.project = ['PROJECTNAME']
block = client.get_block(row.id)
block.children.add_new(TextBlock, title=description)
toggle = block.children.add_new(ToggleBlock, title="__"+str(numberOfFilesChanged)+" File(s) changed__")
toggle.children.add_new(TextBlock, title=fileschanged)