graykode

(fixed) escape when example.header.new_path is None, (fixed) if isadded and not …

…isdeleted then go to added route else diff route
...@@ -70,24 +70,28 @@ def commit_autosuggestions(diffs, endpoint): ...@@ -70,24 +70,28 @@ def commit_autosuggestions(diffs, endpoint):
70 added = tokenizing(" ".join(added), endpoint=endpoint) 70 added = tokenizing(" ".join(added), endpoint=endpoint)
71 deleted = tokenizing(" ".join(deleted), endpoint=endpoint) 71 deleted = tokenizing(" ".join(deleted), endpoint=endpoint)
72 72
73 - if isadded and isdeleted and example.header.new_path: 73 + _path = example.header.new_path \
74 - data = {"idx": idx, "added" : added, "deleted" : deleted} 74 + if example.header.new_path \
75 - res = requests.post( 75 + else example.header.old_path
76 - f'{endpoint}/diff', 76 + if _path:
77 - data=json.dumps(data), 77 + if isadded and not isdeleted:
78 - headers={'Content-Type': 'application/json; charset=utf-8'} 78 + data = {"idx": idx, "added" : added, "deleted" : deleted}
79 - ) 79 + res = requests.post(
80 - commit = json.loads(res.text) 80 + f'{endpoint}/added',
81 - commit_message[example.header.new_path] = commit 81 + data=json.dumps(data),
82 - else: 82 + headers={'Content-Type': 'application/json; charset=utf-8'}
83 - data = {"idx": idx, "added": added, "deleted": deleted} 83 + )
84 - res = requests.post( 84 + commit = json.loads(res.text)
85 - f'{endpoint}/added', 85 + commit_message[_path] = commit
86 - data=json.dumps(data), 86 + else:
87 - headers={'Content-Type': 'application/json; charset=utf-8'} 87 + data = {"idx": idx, "added": added, "deleted": deleted}
88 - ) 88 + res = requests.post(
89 - commit = json.loads(res.text) 89 + f'{endpoint}/diff',
90 - commit_message[example.header.new_path] = commit 90 + data=json.dumps(data),
91 + headers={'Content-Type': 'application/json; charset=utf-8'}
92 + )
93 + commit = json.loads(res.text)
94 + commit_message[_path] = commit
91 return commit_message 95 return commit_message
92 96
93 def commit(messages): 97 def commit(messages):
......