Skip to content

Commit 6e35a04

Browse files
committed
(fixed) escape when example.header.new_path is None, (fixed) if isadded and not isdeleted then go to added route else diff route
1 parent 5dca7a0 commit 6e35a04

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

commit/commit.py

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -70,24 +70,28 @@ def commit_autosuggestions(diffs, endpoint):
7070
added = tokenizing(" ".join(added), endpoint=endpoint)
7171
deleted = tokenizing(" ".join(deleted), endpoint=endpoint)
7272

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

9397
def commit(messages):

0 commit comments

Comments
 (0)