git-project-manager/README.md

178 lines
6.8 KiB
Markdown
Raw Normal View History

2024-12-27 22:42:44 +00:00
# Git Project Manager
2023-12-04 21:53:01 +00:00
2023-12-10 16:41:08 +00:00
## Purpose
The goal of this utility is to provide a fuzzy-find method of locating, cloning,
2024-12-27 22:42:44 +00:00
and using Git projects -- along with your preferred aliases, autocompletion,
2023-12-10 16:41:08 +00:00
and shortcuts.
2024-12-27 22:42:44 +00:00
This supports GitHub, GitLab, and Gitea remotes.
2025-01-01 02:37:26 +00:00
## Installation
Install git-project-manager using `go`:
`go install -v gitea.libretechconsulting.com/rmcguire/git-project-manager@latest`
OR Download a pre-built binary:
[https://gitea.libretechconsulting.com/rmcguire/-/packages/generic/git-project-manager](https://gitea.libretechconsulting.com/rmcguire/-/packages/generic/git-project-manager)
## Setup
**Generate a new config file:**
`git-project-manager config generate --write`
**For handy aliases and shell helpers:**
- Download `https://gitea.libretechconsulting.com/rmcguire/git-project-manager/raw/branch/main/contrib/gpm_func_omz.zsh`
- Implement however you like (e.g. copy to ~/.oh-my-zsh/custom/)
For just completion only, source completions from git-project-manager (e.g. for zsh, `source <(git-project-manager completion zsh)`)
_The following commands assume you've loaded the gpm alias and help funcs._
**Index your git repos**
`gpm cache load`
**Add your first project**
`padd` (gpm project add)
**Go to your project, fuzzily**
`pgo`
2024-12-19 19:51:26 +00:00
## Documentation
2024-12-27 22:42:44 +00:00
[Full documentation is available in docs/](./docs/git-project-manager.md)
2024-12-19 19:51:26 +00:00
2023-12-10 16:41:08 +00:00
## Functionality
2024-05-07 16:07:39 +00:00
This program will try like hell to help you fuzzily find a project,
2023-12-10 16:41:08 +00:00
and once you've found it, will remember your preference along with whatever crazy
thing your lizard brain wants to call it.
Do you think of a project called terraform as infra-stuff? No problem, just let
gpm know that and it'll remember.
The basic workflow looks like this:
1. **Config** -- generate a config file
2023-12-10 16:41:08 +00:00
1. **Cache** -- load your cache to make things super quick
2023-12-10 16:43:31 +00:00
1. you only need to update it if there are new projects the cache is unaware of
1. **Add** -- find your project, give it any extra aliases you want
2023-12-10 16:45:21 +00:00
1. run `gpm project add` (or `padd` if using the provided shell defaults)
2023-12-10 16:43:31 +00:00
1. **Go** -- go to your project, fuzzy searching by alias
2023-12-10 16:45:21 +00:00
1. clones your project if that's never been done
2023-12-10 16:43:31 +00:00
1. the provided `pgo` func makes it easy
1. **Open** -- rather than simply changing directories to a project, open it in your IDE
1. **Manage** -- fine-tune your aliases, making it easy to nail them without fuzzy stuff
2023-12-10 16:45:21 +00:00
1. if you are lazy in your aliases, you'll be fuzzy finding a lot
2023-12-10 16:43:31 +00:00
1. match your alias exactly (or have only one result) and you go there right away
1. positive reinforcement given for solid alias behavior
1. manage aliases using `gpm alias add` or `gpm alias delete`
1. **List** -- get a list of your configured projects any time with `plist`
1. **Reward** -- buy the author a beer, because this thing is a time saver
2023-12-10 16:41:08 +00:00
2023-12-11 15:39:48 +00:00
### Config Sample
```yaml
2024-01-18 18:11:44 +00:00
remotes:
- host: https://github.com/rdmcguire # add user for multiple keys
token: <your token here>
name: github-rdmcguire
type: "github" # github, gitlab, gitea supported
cloneProto: ssh
2023-12-11 15:39:48 +00:00
logLevel: info
cache:
ttl: 168h
2023-12-11 15:41:24 +00:00
load:
2024-01-18 18:11:44 +00:00
ownerOnly: false # if true, only owned projects will be indexed
2023-12-11 15:39:48 +00:00
```
2024-01-18 18:11:44 +00:00
## Usage
### Global Flags
- The `--remote` flag limits all subcommands to one or more specified remotes
- The `--logLevel [debug|error|info|warn]` flag sets logging, but is permanent in the config file
### Basic Usage
Basic usage to prepare your cache, add a project alias (or aliases), and use a project:
1. `gpm cache load`
1. `gpm project add`
1. select with fuzzy search, add extra aliases if preferred
1. `gpm project [go|open] <optional-fuzzy-search-term>`
1. Open will launch your editor, go will change directories, cloning if necessary
### Cache Management
```shell
2024-12-27 22:42:44 +00:00
% git-project-manager cache -h
2024-01-18 18:11:44 +00:00
Contains sub-commands for managing project cache.
2024-12-27 22:42:44 +00:00
The project cache keeps this speedy, without smashing against the Git remote's
2024-01-18 18:11:44 +00:00
API every time a new project is added / searched for
Usage:
2024-12-27 22:42:44 +00:00
git-project-manager cache [command]
2024-01-18 18:11:44 +00:00
Aliases:
cache, a, ln
Available Commands:
2024-12-27 22:42:44 +00:00
clear Clear Git Project Cache
dump Dump Git project cache
load Load Git Project Cache
unlock unlock Git project cache
2024-01-18 18:11:44 +00:00
Flags:
-h, --help help for cache
--ttl duration Duration before cache is re-built in go time.Duration format (default 48h0m0s)
Global Flags:
2024-12-27 22:42:44 +00:00
--config string config file (default is ~/.config/git-project-manager.yaml)
2024-01-18 18:11:44 +00:00
--logLevel string Default log level -- info, warn, error, debug (default "info")
--projectPath string Sets a path for local clones of projects
--remote strings Specify remotes by host for any sub-command. Provide multiple times or comma delimited.
2024-12-27 22:42:44 +00:00
Use "git-project-manager cache [command] --help" for more information about a command.
2024-01-18 18:11:44 +00:00
```
- To update your cache, run `gpm cache load`. You can also specify one or more remotes
with `--remote [host]` either multiple times or comma delimited. Command completion works.
- To view basic cache stats, run `gpm cache dump`
- To dump cache projects and any aliases that are set, run `gpm cache dump -f` optionally filtering with `--remote` flags
2023-12-10 05:05:39 +00:00
## TODO
2024-05-07 16:07:39 +00:00
- [x] Don't check remote up unless necessary (project list shouldn't require it)
2024-12-27 22:42:44 +00:00
- [x] Rename to git-project-manager
- [x] Move module to github.com/rdmcguire
2024-01-16 20:56:22 +00:00
- [ ] Add flag for clone timeout for large repos
2024-01-18 18:11:44 +00:00
- [ ] Add `gpm cache prune` command
2024-01-17 21:56:41 +00:00
- [ ] Fix NPE when cache is reset or project for whatever reason leaves an orphaned alias
- [ ] Add TTL check to cache load, and add -f / --force flag to re-build regardless
- [ ] Update README for shell completion, aliases, usage
- [ ] Make a Makefile
- [ ] Add git repo status to project go (up-to-date, pending commits, etc..)
2024-12-27 22:42:44 +00:00
- [ ] Build pipeline, and link to registry for a release binary
2024-01-18 18:11:44 +00:00
- [ ] Add GitHub remote
- [ ] Package for homebrew
- [x] Make generic, this is any git remote, not just GitLab
- [x] Add Gitea support
- [x] Add GitHub support
- [x] Remove separate gitlab/gitea logic and keys, stop supporting legacy keys
- [x] Rename --gitlab flag to --remote
2024-01-17 21:56:41 +00:00
- [x] Add option to select individual remote for `gpm cache load`
- [x] Use multi-gitlab by default in config init
- [x] Update docs for multi-gitlab
- [x] Remove all references to old keys
- [x] Add auto-completion helper for --gitlab flag
- [x] Fix initial setup requiring project path, and set https:// as default for gitlab host
- [x] Add config setters and getters
2024-01-17 21:56:41 +00:00
- [x] For each project loaded, check if it is the same, and do nothing
- [x] prevents clobbering cache on a partial update
- [x] track already loaded projects to diff after load
- [x] Add open command
- [x] config should exist for editor (vim, code, etc..)
- [x] Add fzf to `plist` / `gpm projects list`
- [x] Update `gpm project show` with pterm box like `gpm project list`
2023-12-10 16:17:04 +00:00
- [x] Merge aliases together for same project when selecting
- [x] If after merging there is only one project, go there by default