Gitask is a CLI tool that automates issue transition workflows, integrating with version control systems (VCS). It utilizes a user-defined script to extract the relevant issue ID, and ensures seamless task management with minimal manual intervention.
-
Seamless Issue Transitions: Automatically move issues between statuses ('To Do' to 'In Progress,' 'In Review,' ‘Done') without manually specifying the issue ID.
-
Automated Workflow Actions: Handles related actions such as updating issue metadata, assigning reviewers, and creating pull requests to streamline your workflow.
-
Smart Autocompletion: Supports shell completion for faster command usage.
-
Interactive Configuration: Set up Gitask with a guided interactive process to configure all necessary settings.
pip install gitask
If installation fails try to use a virtual environment:
python3 -m venv gitask-env
source gitask-env/bin/activate
pip install gitask
Gitask uses a combination of environment variables and a JSON configuration file for maximum flexibility and security.
Variable | Description |
---|---|
GITASK_CONFIG_PATH |
Path to the configuration file. Defaults to ~/.gitask_config.json |
GITASK_PMT_TOKEN |
Authentication token for your project management tool |
GITASK_PMT_URL |
Base URL for your project management tool |
GITASK_GIT_TOKEN |
Authentication token for your version control system |
GITASK_GIT_URL |
Base URL for your version control system |
The configuration file is a JSON file that specifies the integration details for the project management tool and the version control system.
{
"pmt-type": "jira",
"vcs-type": "gitlab",
"git-project": "group/project",
"current-ticket": "/workspace/my-scripts/get_issue_id.sh",
"to-do": [
"Open"
],
"in-progress": [
"Start working",
"Back to work"
],
"in-review": [
"To review"
],
"done": [
"Resolve"
],
"git-branch-field": "customfield_10001",
"reviewer-field": "customfield_10101"
}
Field | Description |
---|---|
pmt-type |
Specifies the project management tool being used (e.g., "Jira", "Clickup", "Trello") |
vcs-type |
Specifies the version control system being used (e.g., "GitLab", "GitHub", "Bitbucket") |
git-project |
The path to the project in your VCS (e.g., "group/project" in GitLab or "owner/repo" in GitHub) |
current-ticket |
Path to the script that extracts the current issue ID from your working environment (see Issue ID Extraction) |
to-do |
An array of status transition names that lead to your corresponding “To Do” status |
in-progress |
An array of status transition names that lead to your corresponding “In Progress” status |
in-review |
An array of status transition names that lead to your corresponding “In Review” status |
done |
An array of status transition names that lead to your corresponding “Done” status |
git-branch-field |
The custom issue field ID for storing the git branch name in your PMT (required only if it’s a custom field) |
reviewer-field |
The custom issue field ID for storing the reviewer username in your PMT (required only if it’s a custom field) |
For a guided configuration experience, use the built-in interactive setup: gitask configure
.
This process will:
- Guide you through setting up PMT and VCS connections.
- Configure custom fields.
- Define issue ID extraction script.
- Create the JSON configuration file.
- Enable shell autocompletion (optional).
Moves the ticket to "To Do" status.
gitask open
Moves it to "In Progress".
gitask start-working
Moves it to "In Review".
Updates the issue’s “git branch” and “reviewer” fields.
Creates a pull request.
gitask submit-to-review
Marks the issue as “Done".
gitask done
Guides you through setting up Gitask step by step.
gitask configure
- Jira
- GitLab
Gitask supports pre and post hooks for specific actions.
These hooks allow you to execute custom scripts before or after an action is performed. This can be useful for automating additional custom actions.
Note: The 'configure' command does not support hooks.
Hooks are automatically executed by Gitask when the corresponding action is performed. If a hook script fails, the action will stop, and an error message will be displayed
Hooks can be configured in the Gitask configuration file. Each action can have a pre and/or post hook defined.
Configuration example:
{
"pmt-type": "jira",
"vcs-type": "gitlab",
...,
"hooks": {
"open": {
"pre": "/path/to/pre_open_hook.sh",
"post": "/path/to/post_open_hook.py"
},
"submit-to-review": {
"pre": "/path/to/pre_submit_hook.sh",
"post": "/path/to/post_submit_hook.py"
}
}
}
The hook script can be either a python or a bash executable script. The arguments passed to the sscripts are:
- --pmt-url: The project management tool URL.
- --pmt-token: The authentication token for the project management tool.
- --git-url: The Git repository URL.
- --git-token: The authentication token for the Git repository.
- --issue-key: The current issue key.
import argparse
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--pmt-url")
parser.add_argument("--pmt-token")
parser.add_argument("--git-url")
parser.add_argument("--git-token")
parser.add_argument("--phase")
parser.add_argument("--action")
args = parser.parse_args()
print(f"Running {args.phase} hook for action '{args.action}'")
print(f"PMT URL: {args.pmt_url}")
print(f"GIT URL: {args.git_url}")
#!/bin/bash
for arg in "$@"; do
case $arg in
--pmt-url=*)
PMT_URL="${arg#*=}"
;;
--pmt-token=*)
PMT_TOKEN="${arg#*=}"
;;
esac
done
echo "Pre-hook for 'open' action triggered."
echo "PMT URL: $PMT_URL"
echo "Issue Key: $1"
The current-ticket script should:
- Output the issue ID according to the current git branch.
- It can be extracted from the branch name, commit message, or any other relevant source.
- Have executable permissions.
#!/bin/bash
# Extract JIRA issue ID from current Git branch
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
ISSUE=$(echo "$BRANCH_NAME" | grep -o "COMPANY-[0-9]\{5\}")
echo $ISSUE
If you encounter this error, run the following command to install the required package:
pip install --upgrade python-gitlab --index-url https://pypi.org/simple/
If you’re working within a virtual environment, ensure that it is activated before running the above command.
If your shell does not recognize the gitask command after installation, it’s likely because the virtual environment’s bin directory is not in your PATH.
To fix this, add the path to your virtual environment’s bin directory in your shell profile (e.g., .bashrc, .zshrc):
export PATH="/path/to/your/virtualenv/bin:$PATH"
After making this change, restart your terminal or run source ~/.zshrc
(or equivalent) to apply the update.
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Feel free to submit pull requests or open issues.
- Fork the repository
- Create your feature branch (
git checkout -b username/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin username/amazing-feature
) - Open a Pull Request
For issues, open a GitHub issue or reach out via discussions.