Skip to content

Update jiralib.py #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ verify_ssl = true
[packages]
flask = "~=2.3.0"
requests = "~=2.32.3"
jira = "~=3.0.0"
jira = "~=3.8.0"
logging-formatter-anticrlf = "~=1.2.1"

[dev-packages]
Expand Down
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ inputs:
description: 'Which direction to synchronize in ("gh2jira", "jira2gh" or "both")'
required: false
default: 'both'
issue_state_key:
description: 'Name of the task that will contain the state file. If not provided it will be created a default one.'
required: false
default: '-'
issue_end_state:
description: 'Custom end state'
required: false
Expand All @@ -51,6 +55,7 @@ runs:
INPUTS_SYNC_DIRECTION: ${{ inputs.sync_direction }}
INPUTS_ISSUE_END_STATE: ${{ inputs.issue_end_state }}
INPUTS_ISSUE_REOPEN_STATE: ${{ inputs.issue_reopen_state }}
INPUTS_ISSUE_STATE_KEY: ${{ inputs.issue_state_key }}
run: |
pip3 install pipenv
pipenv install
Expand All @@ -67,5 +72,6 @@ runs:
--jira-project "$INPUTS_JIRA_PROJECT" \
--jira-labels "$INPUTS_JIRA_LABELS" \
--direction "$INPUTS_SYNC_DIRECTION" \
--state-issue "$INPUTS_ISSUE_STATE_KEY" \
--issue-end-state "$INPUTS_ISSUE_END_STATE" \
--issue-reopen-state "$INPUTS_ISSUE_REOPEN_STATE"
8 changes: 4 additions & 4 deletions jiralib.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from jira import JIRA
from io import StringIO
import re
import util
import logging
Expand Down Expand Up @@ -99,7 +100,6 @@ def create_hook(

return resp.json()


class JiraProject:
def __init__(self, jira, projectkey, endstate, reopenstate, labels):
self.jira = jira
Expand Down Expand Up @@ -161,9 +161,9 @@ def save_repo_state(self, repo_id, state, issue_key="-"):
self.j.delete_attachment(a.id)

# attach the new state file
self.jira.attach_file(
i.key, repo_id_to_fname(repo_id), util.state_to_json(state)
)
attachment = StringIO()
attachment.write(util.state_to_json(state))
self.j.add_attachment(issue=i, attachment=attachment, filename=repo_id_to_fname(repo_id))

def create_issue(
self,
Expand Down