{"id":21179769,"url":"https://github.com/benmezger/gjira","last_synced_at":"2025-07-09T23:31:50.071Z","repository":{"id":39924054,"uuid":"264349783","full_name":"benmezger/gjira","owner":"benmezger","description":"Git hook for adding Jira issues and stories to commit body","archived":true,"fork":false,"pushed_at":"2023-03-25T19:54:51.000Z","size":39888,"stargazers_count":78,"open_issues_count":1,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T01:17:55.077Z","etag":null,"topics":["command-line-tool","git","git-hooks","integration","jira","jira-issue","pre-commit","pre-push","python"],"latest_commit_sha":null,"homepage":"https://seds.nl","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/benmezger.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-16T03:20:18.000Z","updated_at":"2024-06-21T13:48:51.000Z","dependencies_parsed_at":"2024-11-20T17:47:39.363Z","dependency_job_id":null,"html_url":"https://github.com/benmezger/gjira","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/benmezger/gjira","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benmezger%2Fgjira","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benmezger%2Fgjira/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benmezger%2Fgjira/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benmezger%2Fgjira/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benmezger","download_url":"https://codeload.github.com/benmezger/gjira/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benmezger%2Fgjira/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264505236,"owners_count":23618909,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["command-line-tool","git","git-hooks","integration","jira","jira-issue","pre-commit","pre-push","python"],"created_at":"2024-11-20T17:34:06.970Z","updated_at":"2025-07-09T23:31:47.906Z","avatar_url":"https://github.com/benmezger.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CircleCI](https://circleci.com/gh/benmezger/gjira.svg?style=svg)](https://circleci.com/gh/benmezger/gjira)\n\n# Note\n\nI've archived this repository since I don't use Jira anymore, so I don't plan on maintaining it – at least for now. \n\n# GJira\n\nGJira fetches a Jira issue based on the current branch name and appends to the\ncommit body.\n\nGJira allows dynamic branches to be set per project and commit template by using\ndynamic Jira attributes.\n\n## Why?\n\nThis came as a requirement from projects I work where makes heavy use of Jira.\nJira has support for [Smart\ncommits](https://confluence.atlassian.com/fisheye/using-smart-commits-960155400.html)\nwhich we use in all projects where I work. This allows us to dynamically move\ncards around depending on their status, and link commits and branches to them.\n\nIt's a neat feature for developers and projects managers, as it removes the\noverhead from developers by having to move cards around manually on each push\nand gives the project manager an insight of the current development workload.\n\n## Requirements\n\n- Python \u003e=3\n- [pre-commit](https://pre-commit.com/)\n\n## Setup\n\n### `prepare-commit-msg`\n\n#### Git commit template\n\nGJira requires a commit template file. GJira supports Jinja2, which allows\ncustomizable templates based on Jira context. For example:\n\n```text\n# The following is automatically by 'commit.template'\n\nJira issue: [{{ key }}]\n{% if parent__key %}Jira story: [{{ parent__key }}]{% endif %}\n{% if summary %}Jira summary: {{ summary }}{% endif %}\n```\n\nThe keys are related to Jira issue attributes. For example:\n\n```text\nissue.fields.worklog.worklogs[0].author\nissue.fields.worklog.worklogs[0].comment\nissue.fields.worklog.worklogs[0].created\nissue.fields.worklog.worklogs[0].id\nissue.fields.worklog.worklogs[0].self\nissue.fields.worklog.worklogs[0].started\nissue.fields.worklog.worklogs[0].timeSpent\nissue.fields.worklog.worklogs[0].timeSpentSeconds\nissue.fields.worklog.worklogs[0].updateAuthor                # dictionary\nissue.fields.worklog.worklogs[0].updated\n\nissue.fields.timetracking.remainingEstimate           # may be NULL or string (\"0m\", \"2h\"...)\nissue.fields.timetracking.remainingEstimateSeconds    # may be NULL or integer\nissue.fields.timetracking.timeSpent                   # may be NULL or string\nissue.fields.timetracking.timeSpentSeconds            # may be NULL or integer\n```\n\nInner issue fields **require** `.` (dot) to be replaced with `__` (double\nunderscore).\n\n#### Branch\n\nGJira find Jira ID by the branch name. You can use a regex to specify the\nlocation for the issue ID, for example: the regex `ISSUE-\\d+` will match\n`ISSUE-123/branch-name` or `ISSUE-123-branch-name` etc.\n\n#### pre-commit configuration\n\nAdd the following repository to your `.pre-commit-config.yml` file\n\n```yaml\n- repo: https://github.com/benmezger/gjira\n  rev: master\n  hooks:\n    - id: gjira\n      args: [\"--board=\u003cboard/project name\u003e\",\n            \"--template=.commit.template\",\n            \"--regex=ISSUE-\\d+\"]\n```\n\nOther gjira args include `--max-retries` for number of HTTP retries before failing.\n\n#### Environment variables\n\nSet the following environment variables:\n\n```sh\nexport jiraserver=\"https://domain.atlassian.net\"\nexport jirauser=\"your@email.com\"\n\n# from: https://id.atlassian.com/manage-profile/security/api-tokens\nexport jiratoken=\"token\"\n```\n\n#### Installing the hook\n\nFinally, install the hook with pre-commit: `pre-commit install --hook-type prepare-commit-msg`.\n\n### `pre-push`\n\nGJira has a `pre-push` hook support, which prevents user from pushing to remote\nif the current branch is not within the specified format.\n\n#### pre-commit configuration\n\nTo enable `pre-push`, set the following to your `.pre-commit-config.yml` file\n\n```yaml\n- repo: https://github.com/benmezger/gjira\n  rev: feat/click-args\n  hooks:\n    ....\n    - id: gjira-check-branch\n      language_version: python3\n      args: [\"--regex=^(feat|refactor|fix|chore)/.*$|^(master|dev(elop)?)$\"]\n```\n\n#### Installing the hook\n\nFinally, install `pre-push` hook: `pre-commit install --hook-type pre-push`\n\n## Demo\n\n### `prepare-commit-msg` using Git in the terminal\n\n[![asciicast](https://asciinema.org/a/GGURgGibHGHII9jaIH5a5w3Yq.svg)](https://asciinema.org/a/GGURgGibHGHII9jaIH5a5w3Yq)\n\n### `prepare-commit-msg` Git in VSCode\n\n![GJira VScode](images/vscode.gif)\n\n### `pre-push`\n\n[![asciicast](https://asciinema.org/a/WZy78gC9H9GUM5Cptt9ulD3OW.svg)](https://asciinema.org/a/WZy78gC9H9GUM5Cptt9ulD3OW)\n\n## Troubleshooting\n\n- GJira is not appending the issue/story to the commit message.\n\n  That's probably because you are not checkout to a branch with the required\n  format or credentials are possibly wrong.\n\n- GJira is not appending the story ID\n\n  That's probably because your issue is not a subtask of a story.\n\n- I need it solved right now!\n\n  Run `pre-commit uninstall --hook-type prepare-commit-msg`. That should disable\n  `prepare-commit-msg`.\n\n## Development\n\n1. Install requirements `pip install -r requirements.txt`\n2. Run `pytest` `pytest .`\n\nThere are two ways of manually running GJira.\n\n1. `python -m gjira` which will run `main()` in `__main__`\n2. You can install the cli to your system `pip install .`\n\n## TODO\n\n- Cache issues the board and check the cache before doing a HTTP request\n  - add `--refresh` parameter to GJira\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenmezger%2Fgjira","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenmezger%2Fgjira","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenmezger%2Fgjira/lists"}