Git Flow Assistant of Rahmasir
Project description
This was created without git flow and only with the main branch 🪖😐🪻
gfr - Git Flow Assistant of Rahmasir
gfr is a powerful command-line tool designed to streamline your Git and GitHub workflows, especially for projects involving microservices managed as Git submodules. It automates common tasks like repository creation, branch management, releases, and more, letting you focus on coding.
Installation
You can install gfr in two ways:
1. From PyPI
The easiest way to install gfr is directly from the Python Package Index (PyPI).
pip install gfr
2. From Source
Alternatively, you can clone the repository and install it locally. This is useful if you want to contribute to the project.
git clone https://github.com/rahmasir/gfr
cd gfr
pip install .
Configuration
Before using gfr, you need to create a .env file in the root directory of your project. This file stores your GitHub credentials securely.
-
Create a file named
.env. -
Add the following variables:
# .env
GITHUB_TOKEN=your_github_personal_access_token
GITHUB_ORGANIZATION=your_github_organization
GITHUB_USERNAME=your_github_username
-
GITHUB_TOKEN: A Personal Access Token withreposcopes. -
GITHUB_ORGANIZATION: The name of your GitHub organization where repositories will be managed. -
GITHUB_USERNAME: Your GitHub username, used for assigning issues and pull requests.
Usage
All commands are run through the ggg entry point.
Project & Repository Management
ggg init
Initializes a new project in an empty directory. This command will:
-
Create a new repository on GitHub.
-
Initialize a local Git repository.
-
Create and push
developanddocbranches. -
Set
developas the default branch on GitHub. -
Switch your local branch to
develop.
# Navigate to an empty directory
mkdir my-new-project && cd my-new-project
# Run the command and follow the prompts
ggg init
ggg create
Creates a new GitHub repository and immediately clones it into your current directory.
ggg create
ggg clone
Fetches a list of all repositories from your organization and provides an interactive menu to choose which one to clone.
ggg clone
ggg addmicro [microservice-name] (alias: am)
Creates a new repository for an existing local directory and adds it to your main project as a Git submodule.
# Assuming 'user-service' is an existing directory
ggg addmicro user-service
Daily Workflow Commands
ggg status
Displays a detailed, color-coded status for the parent project and all submodules, showing the current branch and lists of staged, unstaged, and untracked files.
ggg status
ggg add [service] [files...]
Stages changes in either the parent project or a specific microservice.
-
service: The target repository.-
.: The parent project. -
-: The last used microservice. -
[name]: The name of a specific microservice.
-
-
files...: The files to stage (e.g.,.for all).
# Stage all changes in the parent project
ggg add . .
# Stage a specific file in the 'user-service'
ggg add user-service src/main.py
# Stage all changes in the last used microservice
ggg add - .
ggg commit [service] "[message]"
Commits staged changes. If committing to a microservice on a feature/bugfix branch, it automatically prepends the issue number to the commit message.
# Commit in the parent project
ggg commit . "Initial commit"
# Commit in the 'user-service'
ggg commit user-service "Implement user login endpoint"
ggg ac [service] "[message]"
A convenient shortcut that stages all changes (add .) and commits them in one step.
ggg ac user-service "Refactor user model"
ggg push
Pushes all branches (git push --all) for the parent project and every submodule.
ggg push
ggg acp [service] "[message]"
The ultimate shortcut: stages all changes, commits, and pushes everything in a single command.
ggg acp . "Update project README"
Branching & Feature Management
ggg feature [service] start "[name]"
Starts a new feature workflow. It will:
-
Create a new issue on GitHub with the
enhancementlabel. -
Create a new local branch named
feature/[issue-number]-[feature-name]. -
Switch you to the new branch.
ggg feature . start "User Profile Page"
ggg feature [service] finish
Finishes the current feature branch. It automates the entire closing process:
-
Pushes the branch to the remote.
-
Creates a pull request to
develop. -
Merges the pull request, which automatically closes the associated issue.
-
Deletes the local and remote feature branches.
-
Switches you back to the
developbranch.
ggg feature . finish
ggg bugfix [service] start "[name]" / finish
Works exactly like the feature command but uses the bugfix prefix for branches and the bug label for issues.
ggg bugfix user-service start "Fix login authentication error"
ggg bugfix user-service finish
ggg dev / ggg doc
Quickly switch to the develop or doc branch in the current repository.
ggg dev
Release Management
ggg release [service] start
Initiates the release process. It will:
-
Determine the next version number (major/minor) based on existing Git tags.
-
Create a new
release/[version]branch. -
Prompt you for changelog entries.
-
Create or update the
CHANGELOG.mdfile.
ggg release . start
ggg release [service] finish
Finalizes and publishes a release. This command will:
-
Create and merge pull requests to both
mainanddevelop. -
Create a new version tag on the
mainbranch. -
Generate a new GitHub Release with detailed notes and a link to the commits.
-
Clean up the release branch.
-
Switch you back to
develop.
ggg release . finish
Utility Commands
ggg link
Displays a table with clickable GitHub links for the parent project and all submodules.
ggg link
ggg addasset [service] [asset-name] [destination-file]
Creates a new file from a predefined template.
# Create a MIT LICENCE in user-service
ggg addasset user-service mit LICENCE
How It Works
gfr is built on a few core principles to keep it robust and extensible:
-
Git Submodules: The tool is designed to work with a microservice architecture where each service is a Git submodule within a parent repository. Commands intelligently target either the parent or a specific submodule.
-
State Management: A
.gfr.ymlfile is created at the root of your project to store simple state, such as the last-used microservice. This enables convenient shortcuts like using-as a service name. -
Modular Commands: Each command (
add,commit,release, etc.) is a self-contained module. This makes the codebase easy to navigate and allows for new commands to be added without affecting existing ones. -
Service Layers: The tool separates concerns into different layers. Commands handle user interaction, helpers contain shared business logic, and utilities provide low-level wrappers around Git and the GitHub API.
Contributing
Contributions are welcome! If you have an idea for a new feature or have found a bug, please open an issue. If you'd like to contribute code, please follow these steps:
-
Fork the repository.
-
Create a new branch for your feature (
git checkout -b feature/AmazingFeature). -
Commit your changes (
git commit -m 'Add some AmazingFeature'). -
Push to the branch (
git push origin feature/AmazingFeature). -
Open a pull request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gfr-1.1.2.tar.gz.
File metadata
- Download URL: gfr-1.1.2.tar.gz
- Upload date:
- Size: 21.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.12.2 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c57d8befd45869229034121babc3909b274292c4942654c0a0c53d6e2c8c5140
|
|
| MD5 |
7ad1ceb43e6d54eac8d019959e6261f1
|
|
| BLAKE2b-256 |
6af96410e9ab02ac6a5f3eb1d5f2ec10a8d99024809a7f068a5b3d2d430b6242
|
File details
Details for the file gfr-1.1.2-py3-none-any.whl.
File metadata
- Download URL: gfr-1.1.2-py3-none-any.whl
- Upload date:
- Size: 37.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.12.2 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f85477e6973b112256b148e3062fd997a57773d03fd8d41034cd0d18a8ec98f3
|
|
| MD5 |
b914e7aa94b6b797de3de54fca8dede4
|
|
| BLAKE2b-256 |
13d5b2223ff8c6dfd09f5753063148f504a6f4898a8fce80169fa4949843a78a
|