mirror of
https://github.com/ditkrg/todo-to-issue-action.git
synced 2026-01-22 22:06:43 +00:00
Fix title for closed issues
This commit is contained in:
parent
9b0d7c13ed
commit
a6fcdf71b1
@ -32,7 +32,7 @@ Create a workflow file in your .github/workflows directory as follows:
|
|||||||
|
|
||||||
### workflow.yaml
|
### workflow.yaml
|
||||||
|
|
||||||
Latest version is `v2.4`.
|
Latest version is `v2.4.1`.
|
||||||
|
|
||||||
name: "Workflow"
|
name: "Workflow"
|
||||||
on: ["push"]
|
on: ["push"]
|
||||||
@ -42,7 +42,7 @@ Latest version is `v2.4`.
|
|||||||
steps:
|
steps:
|
||||||
- uses: "actions/checkout@master"
|
- uses: "actions/checkout@master"
|
||||||
- name: "TODO to Issue"
|
- name: "TODO to Issue"
|
||||||
uses: "alstr/todo-to-issue-action@v2.4"
|
uses: "alstr/todo-to-issue-action@v2.4.1"
|
||||||
id: "todo"
|
id: "todo"
|
||||||
with:
|
with:
|
||||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|||||||
30
main.py
30
main.py
@ -72,8 +72,6 @@ def main():
|
|||||||
addition_pattern = re.compile(r'(?<=^\+).*')
|
addition_pattern = re.compile(r'(?<=^\+).*')
|
||||||
deletion_pattern = re.compile(r'(?<=^-).*')
|
deletion_pattern = re.compile(r'(?<=^-).*')
|
||||||
todo_pattern = re.compile(r'(?<=' + label + r'[(\s:]).+')
|
todo_pattern = re.compile(r'(?<=' + label + r'[(\s:]).+')
|
||||||
identifier_pattern = re.compile(r'.+(?=\))')
|
|
||||||
title_pattern = re.compile(r'(?<=\)[\s:]).+')
|
|
||||||
comment_pattern = re.compile(r'(?<=' + comment_marker + r'\s).+')
|
comment_pattern = re.compile(r'(?<=' + comment_marker + r'\s).+')
|
||||||
labels_pattern = re.compile(r'(?<=labels:).+')
|
labels_pattern = re.compile(r'(?<=labels:).+')
|
||||||
assignees_pattern = re.compile(r'(?<=assignees:).+')
|
assignees_pattern = re.compile(r'(?<=assignees:).+')
|
||||||
@ -156,15 +154,7 @@ def main():
|
|||||||
if todo_search:
|
if todo_search:
|
||||||
# A new item was found. Start recording so we can capture multiline TODOs.
|
# A new item was found. Start recording so we can capture multiline TODOs.
|
||||||
previous_line_was_todo = True
|
previous_line_was_todo = True
|
||||||
todo = todo_search.group(0).lstrip()
|
todo = clean_title(todo_search)
|
||||||
identifier_search = identifier_pattern.search(todo)
|
|
||||||
title_search = title_pattern.search(todo)
|
|
||||||
if identifier_search and title_search:
|
|
||||||
todo = f'[{identifier_search.group(0)}] {title_search.group(0).lstrip()}'
|
|
||||||
elif identifier_search:
|
|
||||||
todo = identifier_search.group(0) # Shouldn't really arise.
|
|
||||||
elif title_search:
|
|
||||||
todo = title_search.group(0) # Shouldn't really arise.
|
|
||||||
|
|
||||||
if curr_issue:
|
if curr_issue:
|
||||||
curr_issue['hunk'] = lines
|
curr_issue['hunk'] = lines
|
||||||
@ -193,7 +183,8 @@ def main():
|
|||||||
deletion = deletion_search.group(0)
|
deletion = deletion_search.group(0)
|
||||||
todo_search = todo_pattern.search(deletion, re.IGNORECASE)
|
todo_search = todo_pattern.search(deletion, re.IGNORECASE)
|
||||||
if todo_search:
|
if todo_search:
|
||||||
closed_issues.append(todo_search.group(0).lstrip())
|
todo = clean_title(todo_search)
|
||||||
|
closed_issues.append(todo)
|
||||||
else:
|
else:
|
||||||
lines.append(cleaned_line[1:])
|
lines.append(cleaned_line[1:])
|
||||||
# Let's check if this line continues from a previous deletion.
|
# Let's check if this line continues from a previous deletion.
|
||||||
@ -316,5 +307,20 @@ def main():
|
|||||||
print('Closing issues complete')
|
print('Closing issues complete')
|
||||||
|
|
||||||
|
|
||||||
|
def clean_title(todo_search):
|
||||||
|
identifier_pattern = re.compile(r'.+(?=\))')
|
||||||
|
title_pattern = re.compile(r'(?<=\)[\s:]).+')
|
||||||
|
cleaned_title = todo_search.group(0).lstrip()
|
||||||
|
identifier_search = identifier_pattern.search(cleaned_title)
|
||||||
|
title_search = title_pattern.search(cleaned_title)
|
||||||
|
if identifier_search and title_search:
|
||||||
|
cleaned_title = f'[{identifier_search.group(0)}] {title_search.group(0).lstrip()}'
|
||||||
|
elif identifier_search:
|
||||||
|
cleaned_title = identifier_search.group(0) # Shouldn't really arise.
|
||||||
|
elif title_search:
|
||||||
|
cleaned_title = title_search.group(0) # Shouldn't really arise.
|
||||||
|
return cleaned_title
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user