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 + if example.header.new_path \
75 + else example.header.old_path
76 + if _path:
77 + if isadded and not isdeleted:
74 data = {"idx": idx, "added" : added, "deleted" : deleted} 78 data = {"idx": idx, "added" : added, "deleted" : deleted}
75 res = requests.post( 79 res = requests.post(
76 - f'{endpoint}/diff', 80 + f'{endpoint}/added',
77 data=json.dumps(data), 81 data=json.dumps(data),
78 headers={'Content-Type': 'application/json; charset=utf-8'} 82 headers={'Content-Type': 'application/json; charset=utf-8'}
79 ) 83 )
80 commit = json.loads(res.text) 84 commit = json.loads(res.text)
81 - commit_message[example.header.new_path] = commit 85 + commit_message[_path] = commit
82 else: 86 else:
83 data = {"idx": idx, "added": added, "deleted": deleted} 87 data = {"idx": idx, "added": added, "deleted": deleted}
84 res = requests.post( 88 res = requests.post(
85 - f'{endpoint}/added', 89 + f'{endpoint}/diff',
86 data=json.dumps(data), 90 data=json.dumps(data),
87 headers={'Content-Type': 'application/json; charset=utf-8'} 91 headers={'Content-Type': 'application/json; charset=utf-8'}
88 ) 92 )
89 commit = json.loads(res.text) 93 commit = json.loads(res.text)
90 - commit_message[example.header.new_path] = commit 94 + commit_message[_path] = commit
91 return commit_message 95 return commit_message
92 96
93 def commit(messages): 97 def commit(messages):
......