Compare commits
18 Commits
19c9fa0f76
...
v0.2.3
Author | SHA1 | Date | |
---|---|---|---|
30c65042dd | |||
f14bc47c7b | |||
870760443e | |||
0cc5542ab6 | |||
2f0e1b0d46 | |||
30d86d72ed | |||
70027a9880 | |||
11a2ca434c | |||
b9d7d5a4f2 | |||
96378d047e | |||
888ee5ea4a | |||
5f9cc58ef7 | |||
c78c41f567 | |||
9dd38317b8 | |||
ea10b3c7dd | |||
4fca4a5e3e | |||
06511f5690 | |||
f862973c44 |
84
.gitea/workflows/ci.yml
Normal file
84
.gitea/workflows/ci.yml
Normal file
@ -0,0 +1,84 @@
|
||||
name: Build and Publish
|
||||
on:
|
||||
push:
|
||||
tags: ["v*"]
|
||||
|
||||
env:
|
||||
PACKAGE_NAME: git-project-manager
|
||||
BINARY_PATH: bin
|
||||
BINARY_NAME: git-project-manager
|
||||
GO_MOD_PATH: gitea.libretechconsulting.com/rmcguire/git-project-manager
|
||||
GO_GIT_HOST: gitea.libretechconsulting.com
|
||||
PLATFORMS: linux/amd64 linux/arm64 darwin/amd64 darwin/arm64
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Go Environment
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: '1.23'
|
||||
|
||||
- name: Build Binary
|
||||
env:
|
||||
VERSION: ${{ github.ref_name }}
|
||||
run: make all
|
||||
|
||||
- name: Upload Binaries to Generic Registry
|
||||
env:
|
||||
API_TOKEN: ${{ secrets.API_TOKEN }}
|
||||
run: |
|
||||
for platform in $PLATFORMS; do
|
||||
OS=$(echo $platform | cut -d/ -f1)
|
||||
ARCH=$(echo $platform | cut -d/ -f2)
|
||||
BINARY_FILE="${BINARY_PATH}/${PACKAGE_NAME}-${OS}-${ARCH}"
|
||||
echo "Uploading $BINARY_FILE"
|
||||
if [ -f "$BINARY_FILE" ]; then
|
||||
curl -X PUT \
|
||||
-H "Authorization: token ${API_TOKEN}" \
|
||||
--upload-file "$BINARY_FILE" \
|
||||
"${GITHUB_SERVER_URL}/api/packages/${GITHUB_REPOSITORY_OWNER}/generic/${PACKAGE_NAME}/${{ github.ref_name }}/${PACKAGE_NAME}-${OS}-${ARCH}"
|
||||
else
|
||||
echo "Error: Binary $BINARY_FILE not found."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
- name: Generate and Upload Package to Go Registry
|
||||
env:
|
||||
GOPRIVATE: gitea.libretechconsulting.com/*
|
||||
API_TOKEN: ${{ secrets.API_TOKEN }} # Replace with a Gitea token stored in repository secrets
|
||||
run: |
|
||||
# Set up netrc for Gitea
|
||||
echo "machine ${GO_GIT_HOST} login ${GITHUB_REPOSITORY_OWNER} password ${API_TOKEN}" > ~/.netrc
|
||||
chmod 0600 ~/.netrc
|
||||
|
||||
# Package and get mod info
|
||||
go mod download -x --json ${GO_MOD_PATH}@${{ github.ref_name }} | tee package.json
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "Failed to generage go package archive for ${GO_MOD_PATH}@${{ github.ref_name }}"
|
||||
exit 1
|
||||
fi
|
||||
ZIPFILE=$( jq .Zip < package.json | tr -d '"' )
|
||||
|
||||
# Upload to Gitea go registry
|
||||
echo "Uploading go package ${ZIPFILE}"
|
||||
curl -X PUT \
|
||||
-H "Authorization: token ${API_TOKEN}" \
|
||||
--upload-file ${ZIPFILE} \
|
||||
"${GITHUB_SERVER_URL}/api/packages/${GITHUB_REPOSITORY_OWNER}/go/upload"
|
||||
|
||||
- name: Run Go List
|
||||
env:
|
||||
TAG_NAME: ${{ github.ref_name }} # Use the pushed tag name
|
||||
run: |
|
||||
if [[ "$TAG_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
GOPROXY=proxy.golang.org go list -m gitea.libretechconsulting.com/${GITHUB_REPOSITORY}@$TAG_NAME
|
||||
else
|
||||
echo "Error: Invalid tag format '$TAG_NAME'. Expected 'vX.X.X'."
|
||||
exit 1
|
||||
fi
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
gitlab-project-manager
|
||||
bin/*
|
||||
|
20
.vscode/launch.json
vendored
20
.vscode/launch.json
vendored
@ -13,6 +13,26 @@
|
||||
"--remote",
|
||||
"https://gitea.libretechconsulting.com"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "List Aliases",
|
||||
"type": "delve",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}",
|
||||
"args": [
|
||||
"alias",
|
||||
"ls"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Generate Docs",
|
||||
"type": "delve",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}",
|
||||
"args": [
|
||||
"docs",
|
||||
"md"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
33
Makefile
Normal file
33
Makefile
Normal file
@ -0,0 +1,33 @@
|
||||
CMD_NAME := git-project-manager
|
||||
|
||||
.PHONY: all test build install docs clean
|
||||
|
||||
VERSION ?= development # Default to "development" if VERSION is not set
|
||||
PLATFORMS := linux/amd64 linux/arm64 darwin/amd64 darwin/arm64
|
||||
OUTPUT_DIR := bin
|
||||
PKG := gitea.libretechconsulting.com/rmcguire/git-project-manager
|
||||
|
||||
all: test build install docs
|
||||
|
||||
test:
|
||||
go test -v ./...
|
||||
|
||||
build: test
|
||||
@echo "Building for platforms: $(PLATFORMS)"
|
||||
@for platform in $(PLATFORMS); do \
|
||||
OS=$$(echo $$platform | cut -d/ -f1); \
|
||||
ARCH=$$(echo $$platform | cut -d/ -f2); \
|
||||
OUTPUT="$(OUTPUT_DIR)/$(CMD_NAME)-$$OS-$$ARCH"; \
|
||||
GOOS=$$OS GOARCH=$$ARCH go build -ldflags "-X $(PKG)/cmd.Version=$(VERSION)" -o $$OUTPUT; \
|
||||
echo "Built $$OUTPUT"; \
|
||||
done
|
||||
go build -ldflags "-X $(PKG)/cmd.Version=$(VERSION)" -o bin/${CMD_NAME}
|
||||
|
||||
install:
|
||||
go install -v -ldflags "-X $(PKG)/cmd.Version=$(VERSION)" .
|
||||
|
||||
docs:
|
||||
bin/${CMD_NAME} docs md
|
||||
|
||||
clean:
|
||||
rm -rf bin/${CMD_NAME}
|
38
README.md
38
README.md
@ -1,11 +1,17 @@
|
||||
# GitLab Project Manager
|
||||
# Git Project Manager
|
||||
|
||||
## Purpose
|
||||
|
||||
The goal of this utility is to provide a fuzzy-find method of locating, cloning,
|
||||
and using GitLab projects -- along with your preferred aliases, autocompletion,
|
||||
and using Git projects -- along with your preferred aliases, autocompletion,
|
||||
and shortcuts.
|
||||
|
||||
This supports GitHub, GitLab, and Gitea remotes.
|
||||
|
||||
## Documentation
|
||||
|
||||
[Full documentation is available in docs/](./docs/git-project-manager.md)
|
||||
|
||||
## Functionality
|
||||
|
||||
This program will try like hell to help you fuzzily find a project,
|
||||
@ -40,8 +46,8 @@ The basic workflow looks like this:
|
||||
1. Copy `contrib/gpm_func_omz.zsh` into your `~/.oh-my-zsh/custom/` path, or just source from your bashrc/zshrc
|
||||
1. Generate config file: `gpm config gen --write`
|
||||
1. You can run this any time to update settings
|
||||
1. It will only add one GitLab, so update the file for multiple
|
||||
1. Run `gpm cache load` (if aliases is in-place, otherwise `gitlab-project-manager cache load`)
|
||||
1. It will only add one Git remote, so update the file for multiple
|
||||
1. Run `gpm cache load` (if aliases is in-place, otherwise `git-project-manager cache load`)
|
||||
|
||||
### Config Sample
|
||||
```yaml
|
||||
@ -77,34 +83,34 @@ Basic usage to prepare your cache, add a project alias (or aliases), and use a p
|
||||
### Cache Management
|
||||
|
||||
```shell
|
||||
% gitlab-project-manager cache -h
|
||||
% git-project-manager cache -h
|
||||
Contains sub-commands for managing project cache.
|
||||
The project cache keeps this speedy, without smashing against the GitLab
|
||||
The project cache keeps this speedy, without smashing against the Git remote's
|
||||
API every time a new project is added / searched for
|
||||
|
||||
Usage:
|
||||
gitlab-project-manager cache [command]
|
||||
git-project-manager cache [command]
|
||||
|
||||
Aliases:
|
||||
cache, a, ln
|
||||
|
||||
Available Commands:
|
||||
clear Clear GitLab Project Cache
|
||||
dump Dump GitLab project cache
|
||||
load Load GitLab Project Cache
|
||||
unlock unlock GitLab project cache
|
||||
clear Clear Git Project Cache
|
||||
dump Dump Git project cache
|
||||
load Load Git Project Cache
|
||||
unlock unlock Git project cache
|
||||
|
||||
Flags:
|
||||
-h, --help help for cache
|
||||
--ttl duration Duration before cache is re-built in go time.Duration format (default 48h0m0s)
|
||||
|
||||
Global Flags:
|
||||
--config string config file (default is ~/.config/gitlab-project-manager.yaml)
|
||||
--config string config file (default is ~/.config/git-project-manager.yaml)
|
||||
--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.
|
||||
|
||||
Use "gitlab-project-manager cache [command] --help" for more information about a command.
|
||||
Use "git-project-manager cache [command] --help" for more information about a command.
|
||||
```
|
||||
|
||||
- To update your cache, run `gpm cache load`. You can also specify one or more remotes
|
||||
@ -115,8 +121,8 @@ Use "gitlab-project-manager cache [command] --help" for more information about a
|
||||
## TODO
|
||||
|
||||
- [x] Don't check remote up unless necessary (project list shouldn't require it)
|
||||
- [ ] Rename to git-project-manager
|
||||
- [ ] Move module from gitlab.sweetwater.com to github.com/rdmcguire
|
||||
- [x] Rename to git-project-manager
|
||||
- [x] Move module to github.com/rdmcguire
|
||||
- [ ] Add flag for clone timeout for large repos
|
||||
- [ ] Add `gpm cache prune` command
|
||||
- [ ] Fix NPE when cache is reset or project for whatever reason leaves an orphaned alias
|
||||
@ -124,7 +130,7 @@ Use "gitlab-project-manager cache [command] --help" for more information about a
|
||||
- [ ] Update README for shell completion, aliases, usage
|
||||
- [ ] Make a Makefile
|
||||
- [ ] Add git repo status to project go (up-to-date, pending commits, etc..)
|
||||
- [ ] Build pipeline, and link to gitlab registry for a release binary
|
||||
- [ ] Build pipeline, and link to registry for a release binary
|
||||
- [ ] Add GitHub remote
|
||||
- [ ] Package for homebrew
|
||||
- [x] Make generic, this is any git remote, not just GitLab
|
||||
|
25
cmd/alias.go
25
cmd/alias.go
@ -1,25 +0,0 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var aliasCmd = &cobra.Command{
|
||||
Use: "alias",
|
||||
Aliases: []string{"aliases", "a"},
|
||||
Short: "Manage project aliases",
|
||||
Long: aliasCmdLong,
|
||||
// Just re-use the hooks for project
|
||||
PersistentPreRun: initProjectCmd,
|
||||
PersistentPostRun: postProjectCmd,
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(aliasCmd)
|
||||
}
|
||||
|
||||
func mustHaveAliases(cmd *cobra.Command, args []string) {
|
||||
if len(projectCache.Aliases) == 0 {
|
||||
plog.Fatal("No aliases set, nothing to " + cmd.Name())
|
||||
}
|
||||
}
|
38
cmd/alias/alias.go
Normal file
38
cmd/alias/alias.go
Normal file
@ -0,0 +1,38 @@
|
||||
package alias
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/util"
|
||||
)
|
||||
|
||||
var AliasCmd = &cobra.Command{
|
||||
Use: "alias",
|
||||
Aliases: []string{"aliases", "a"},
|
||||
Short: "Manage project aliases",
|
||||
Long: util.AliasCmdLong,
|
||||
// Just re-use the hooks for project
|
||||
PersistentPreRun: util.InitProjects,
|
||||
PersistentPostRun: util.PostProjectCmd,
|
||||
}
|
||||
|
||||
var utils *util.Utils
|
||||
|
||||
func aliasCmdPreRun(cmd *cobra.Command, args []string) {
|
||||
utils = util.MustFromCtx(cmd.Context())
|
||||
util.InitProjects(cmd, args)
|
||||
}
|
||||
|
||||
func mustHaveAliases(cmd *cobra.Command, args []string) {
|
||||
utils = util.MustFromCtx(cmd.Context())
|
||||
|
||||
if len(utils.Cache().Aliases) == 0 {
|
||||
utils.Logger().Fatal("No aliases set, nothing to " + cmd.Name())
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
AliasCmd.AddCommand(aliasAddCmd)
|
||||
AliasCmd.AddCommand(aliasListCmd)
|
||||
AliasCmd.AddCommand(aliasDeleteCmd)
|
||||
}
|
116
cmd/alias/alias_add.go
Normal file
116
cmd/alias/alias_add.go
Normal file
@ -0,0 +1,116 @@
|
||||
package alias
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/pterm/pterm"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/util"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/cache"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/projects"
|
||||
)
|
||||
|
||||
var aliasAddCmd = &cobra.Command{
|
||||
Use: "add",
|
||||
Aliases: []string{"set", "a", "s"},
|
||||
Short: "Add a project alias",
|
||||
Args: cobra.ArbitraryArgs,
|
||||
Long: util.AliasAddCmdLong,
|
||||
Run: runAddAliasCmd,
|
||||
}
|
||||
|
||||
func runAddAliasCmd(cmd *cobra.Command, args []string) {
|
||||
var project *projects.Project
|
||||
|
||||
// Check by flag
|
||||
if projectID := viper.GetInt(util.ViperAliasAddPID); projectID > 0 {
|
||||
utils.Logger().Debug(fmt.Sprintf("Adding for inbound project ID %d", projectID))
|
||||
|
||||
projects := utils.Cache().GetProjectsByID(projectID)
|
||||
if len(projects) > 0 {
|
||||
project = projects[0]
|
||||
}
|
||||
if len(projects) > 1 {
|
||||
utils.Logger().
|
||||
Warn(fmt.Sprintf("found %d remotes with same ID, using first remote", len(projects)))
|
||||
}
|
||||
}
|
||||
|
||||
// Check by arg
|
||||
if len(args) > 0 {
|
||||
project = utils.FzfFindProject(&util.FzfProjectOpts{Ctx: cmd.Context(), Search: utils.SearchStringFromArgs(args)})
|
||||
}
|
||||
|
||||
// Collect by fzf
|
||||
if project == nil {
|
||||
var err error
|
||||
project, err = utils.FzfProject(&util.FzfProjectOpts{Ctx: cmd.Context()})
|
||||
if err != nil || project == nil {
|
||||
utils.Logger().Fatal("No project to alias, nothing to do", utils.Logger().Args("error", err))
|
||||
}
|
||||
}
|
||||
|
||||
AddNewAliases(cmd, project.GetID())
|
||||
}
|
||||
|
||||
func AddNewAliases(cmd *cobra.Command, projectID string) {
|
||||
u := util.MustFromCtx(cmd.Context())
|
||||
project := u.Cache().GetProjectByID(projectID)
|
||||
if project == nil {
|
||||
u.Logger().Error("Failed to find project to alias", u.Logger().Args("projectID", projectID))
|
||||
return
|
||||
}
|
||||
|
||||
// Collect the aliases
|
||||
aliases := PromptAliasesForProject(cmd, project)
|
||||
|
||||
// Add aliases
|
||||
for _, a := range aliases {
|
||||
a = strings.Trim(a, " '\"%<>|`")
|
||||
if a == "" {
|
||||
continue
|
||||
}
|
||||
if err := u.Cache().AddAlias(a, project); err != nil {
|
||||
u.Logger().Debug("Skipping alias add", u.Logger().Args(
|
||||
"error", err,
|
||||
"alias", a,
|
||||
))
|
||||
} else {
|
||||
u.Logger().Info("Successfully added alias to project", u.Logger().Args(
|
||||
"project", project.String(),
|
||||
"alias", a,
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func PromptAliasesForProject(cmd *cobra.Command, p *projects.Project) []string {
|
||||
u := util.MustFromCtx(cmd.Context())
|
||||
aliases := u.Cache().GetProjectAliases(p)
|
||||
if len(aliases) > 0 {
|
||||
u.Logger().Info("Adding aliases to project", u.Logger().Args(
|
||||
"project", p.String(),
|
||||
"existingAliases", cache.ProjectAliasesString(aliases),
|
||||
))
|
||||
} else {
|
||||
pterm.Info.Printfln("Adding aliases to %s", p.Name)
|
||||
}
|
||||
|
||||
response, _ := pterm.DefaultInteractiveTextInput.
|
||||
WithMultiLine(false).
|
||||
WithDefaultValue(p.Path + " ").
|
||||
Show("Enter aliases separated by space")
|
||||
|
||||
return strings.Split(response, " ")
|
||||
}
|
||||
|
||||
func init() {
|
||||
aliasAddCmd.PersistentFlags().Int(util.FlagProjectID, 0, "Specify a project by ID")
|
||||
|
||||
aliasAddCmd.RegisterFlagCompletionFunc(util.FlagProjectID, util.ValidProjectIdFunc)
|
||||
|
||||
viper.BindPFlag(util.ViperAliasAddPID, aliasAddCmd.Flag(util.FlagProjectID))
|
||||
}
|
@ -1,19 +1,20 @@
|
||||
package cmd
|
||||
package alias
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/util"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/projects"
|
||||
"github.com/pterm/pterm"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/projects"
|
||||
)
|
||||
|
||||
var aliasDeleteCmd = &cobra.Command{
|
||||
Use: "delete [fuzzy project or alias]",
|
||||
Aliases: []string{"rm", "del", "d"},
|
||||
Short: "Delete a project alias",
|
||||
Long: aliasDeleteCmdLong,
|
||||
Long: util.AliasDeleteCmdLong,
|
||||
PreRun: mustHaveAliases,
|
||||
Run: runDeleteAliasCmd,
|
||||
}
|
||||
@ -22,32 +23,32 @@ func runDeleteAliasCmd(cmd *cobra.Command, args []string) {
|
||||
var project *projects.Project
|
||||
var err error
|
||||
|
||||
fzfOpts := &fzfProjectOpts{
|
||||
fzfOpts := &util.FzfProjectOpts{
|
||||
Ctx: cmd.Context(),
|
||||
MustHaveAlias: true,
|
||||
}
|
||||
|
||||
if len(args) > 0 {
|
||||
fzfOpts.Search = searchStringFromArgs(args)
|
||||
project = fzfFindProject(fzfOpts)
|
||||
fzfOpts.Search = utils.SearchStringFromArgs(args)
|
||||
project = utils.FzfFindProject(fzfOpts)
|
||||
} else {
|
||||
project, err = fzfProject(fzfOpts)
|
||||
project, err = utils.FzfProject(fzfOpts)
|
||||
}
|
||||
|
||||
if project == nil || err != nil {
|
||||
plog.Fatal("Failed to find project to delete aliases from", plog.Args(
|
||||
utils.Logger().Fatal("Failed to find project to delete aliases from", utils.Logger().Args(
|
||||
"error", err,
|
||||
))
|
||||
}
|
||||
|
||||
aliasStrings := projectCache.GetProjectAliasStrings(project)
|
||||
aliasStrings := utils.Cache().GetProjectAliasStrings(project)
|
||||
|
||||
deletionCandidates, err := pterm.DefaultInteractiveMultiselect.
|
||||
WithOptions(aliasStrings).
|
||||
Show()
|
||||
|
||||
if err != nil || len(deletionCandidates) < 1 {
|
||||
plog.Fatal("Failed to find project to delete aliases from", plog.Args(
|
||||
utils.Logger().Fatal("Failed to find project to delete aliases from", utils.Logger().Args(
|
||||
"error", err,
|
||||
))
|
||||
}
|
||||
@ -61,26 +62,25 @@ func runDeleteAliasCmd(cmd *cobra.Command, args []string) {
|
||||
Show()
|
||||
|
||||
if !confirm {
|
||||
plog.Warn("Alias deletion cancelled")
|
||||
utils.Logger().Warn("Alias deletion cancelled")
|
||||
continue
|
||||
}
|
||||
|
||||
plog.Info("Deleting alias", plog.Args(
|
||||
utils.Logger().Info("Deleting alias", utils.Logger().Args(
|
||||
"project", project.String(),
|
||||
"alias", a,
|
||||
))
|
||||
|
||||
projectCache.DeleteAlias(projectCache.GetAliasByName(a))
|
||||
utils.Cache().DeleteAlias(utils.Cache().GetAliasByName(a))
|
||||
}
|
||||
|
||||
fmt.Println(projectCache.ProjectString(project))
|
||||
fmt.Println(utils.Cache().ProjectString(project))
|
||||
}
|
||||
|
||||
func init() {
|
||||
aliasCmd.AddCommand(aliasDeleteCmd)
|
||||
aliasDeleteCmd.PersistentFlags().Int("projectID", 0, "Specify a project by ID")
|
||||
|
||||
aliasDeleteCmd.RegisterFlagCompletionFunc("projectID", validProjectIdFunc)
|
||||
aliasDeleteCmd.RegisterFlagCompletionFunc("projectID", util.ValidProjectIdFunc)
|
||||
|
||||
viper.BindPFlag("alias.delete.projectID", aliasDeleteCmd.Flag("projectID"))
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cmd
|
||||
package alias
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@ -6,6 +6,8 @@ import (
|
||||
"github.com/pterm/pterm"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/util"
|
||||
)
|
||||
|
||||
// listCmd represents the list command
|
||||
@ -14,20 +16,24 @@ var aliasListCmd = &cobra.Command{
|
||||
Aliases: []string{"dump", "show", "ls", "ll", "l"},
|
||||
Short: "List Aliases",
|
||||
PreRun: mustHaveAliases,
|
||||
Long: aliasListCmdLong,
|
||||
Long: util.AliasListCmdLong,
|
||||
Run: runListAliasCmd,
|
||||
}
|
||||
|
||||
func runListAliasCmd(cmd *cobra.Command, args []string) {
|
||||
remotes := viper.GetStringSlice(FlagRemote)
|
||||
pterm.DefaultBox.
|
||||
remotes := viper.GetStringSlice(util.FlagRemote)
|
||||
aliases := utils.Cache().AliasesByProjectString(remotes...)
|
||||
|
||||
printer := pterm.DefaultBox.
|
||||
WithLeftPadding(5).WithRightPadding(5).
|
||||
WithBoxStyle(&pterm.Style{pterm.FgLightBlue}).
|
||||
WithTitle(pterm.Bold.Sprint(pterm.LightGreen("Aliases by Project"))).
|
||||
Print("\n" + projectCache.AliasesByProjectString(remotes...))
|
||||
fmt.Print("\n\n")
|
||||
WithTitle(pterm.Bold.Sprint(pterm.LightGreen("Aliases by Project")))
|
||||
|
||||
if len(aliases) < 1 {
|
||||
printer.Print("\n" + "No Aliases Found")
|
||||
} else {
|
||||
printer.Print("\n" + aliases)
|
||||
}
|
||||
|
||||
func init() {
|
||||
aliasCmd.AddCommand(aliasListCmd)
|
||||
fmt.Print("\n\n")
|
||||
}
|
106
cmd/alias_add.go
106
cmd/alias_add.go
@ -1,106 +0,0 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/pterm/pterm"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/cache"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/projects"
|
||||
)
|
||||
|
||||
var aliasAddCmd = &cobra.Command{
|
||||
Use: "add",
|
||||
Aliases: []string{"set", "a", "s"},
|
||||
Short: "Add a project alias",
|
||||
Args: cobra.ArbitraryArgs,
|
||||
Long: aliasAddCmdLong,
|
||||
Run: runAddAliasCmd,
|
||||
}
|
||||
|
||||
func runAddAliasCmd(cmd *cobra.Command, args []string) {
|
||||
var project *projects.Project
|
||||
|
||||
// Check by flag
|
||||
if projectID := viper.GetInt(ViperAliasAddPID); projectID > 0 {
|
||||
plog.Debug(fmt.Sprintf("Adding for inbound project ID %d", projectID))
|
||||
project = projectCache.GetProjectByID(projectID)
|
||||
}
|
||||
|
||||
// Check by arg
|
||||
if len(args) > 0 {
|
||||
project = fzfFindProject(&fzfProjectOpts{Ctx: cmd.Context(), Search: searchStringFromArgs(args)})
|
||||
}
|
||||
|
||||
// Collect by fzf
|
||||
if project == nil {
|
||||
var err error
|
||||
project, err = fzfProject(&fzfProjectOpts{Ctx: cmd.Context()})
|
||||
if err != nil || project == nil {
|
||||
plog.Fatal("No project to alias, nothing to do", plog.Args("error", err))
|
||||
}
|
||||
}
|
||||
|
||||
addNewAliases(project.ID)
|
||||
}
|
||||
|
||||
func addNewAliases(projectID int) {
|
||||
project := projectCache.GetProjectByID(projectID)
|
||||
if project == nil {
|
||||
plog.Error("Failed to find project to alias", plog.Args("projectID", projectID))
|
||||
return
|
||||
}
|
||||
|
||||
// Collect the aliases
|
||||
aliases := promptAliasesForProject(project)
|
||||
|
||||
// Add aliases
|
||||
for _, a := range aliases {
|
||||
a = strings.Trim(a, " '\"%<>|`")
|
||||
if a == "" {
|
||||
continue
|
||||
}
|
||||
if err := projectCache.AddAlias(a, project.ID, project.Remote); err != nil {
|
||||
plog.Debug("Skipping alias add", plog.Args(
|
||||
"error", err,
|
||||
"alias", a,
|
||||
))
|
||||
} else {
|
||||
plog.Info("Successfully added alias to project", plog.Args(
|
||||
"project", project.String(),
|
||||
"alias", a,
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func promptAliasesForProject(p *projects.Project) []string {
|
||||
aliases := projectCache.GetProjectAliases(p)
|
||||
if len(aliases) > 0 {
|
||||
plog.Info("Adding aliases to project", plog.Args(
|
||||
"project", p.String(),
|
||||
"existingAliases", cache.ProjectAliasesString(aliases),
|
||||
))
|
||||
} else {
|
||||
pterm.Info.Printfln("Adding aliases to %s", p.Name)
|
||||
}
|
||||
|
||||
response, _ := pterm.DefaultInteractiveTextInput.
|
||||
WithMultiLine(false).
|
||||
WithDefaultValue(p.Path + " ").
|
||||
Show("Enter aliases separated by space")
|
||||
|
||||
return strings.Split(response, " ")
|
||||
}
|
||||
|
||||
func init() {
|
||||
aliasCmd.AddCommand(aliasAddCmd)
|
||||
aliasAddCmd.PersistentFlags().Int(FlagProjectID, 0, "Specify a project by ID")
|
||||
|
||||
aliasAddCmd.RegisterFlagCompletionFunc(FlagProjectID, validProjectIdFunc)
|
||||
|
||||
viper.BindPFlag(ViperAliasAddPID, aliasAddCmd.Flag(FlagProjectID))
|
||||
}
|
37
cmd/cache.go
37
cmd/cache.go
@ -1,37 +0,0 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/cache"
|
||||
)
|
||||
|
||||
var projectCache *cache.Cache
|
||||
|
||||
var cacheCmd = &cobra.Command{
|
||||
Use: "cache",
|
||||
Aliases: []string{"a", "ln"},
|
||||
Short: "Manage GitLab project cache",
|
||||
Long: cacheCmdLong,
|
||||
}
|
||||
|
||||
func runCacheCmd(cmd *cobra.Command, args []string) {
|
||||
initProjectCache(cmd, args)
|
||||
projectCache.LockCache()
|
||||
}
|
||||
|
||||
func postCacheCmd(cmd *cobra.Command, args []string) {
|
||||
postProjectCache(cmd, args)
|
||||
projectCache.UnlockCache()
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(cacheCmd)
|
||||
|
||||
cacheCmd.PersistentFlags().Duration("ttl", 48*time.Hour,
|
||||
"Duration before cache is re-built in go time.Duration format")
|
||||
|
||||
viper.BindPFlags(cacheCmd.Flags())
|
||||
}
|
43
cmd/cache/cache.go
vendored
Normal file
43
cmd/cache/cache.go
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/util"
|
||||
)
|
||||
|
||||
var CacheCmd = &cobra.Command{
|
||||
Use: "cache",
|
||||
Aliases: []string{"a", "ln"},
|
||||
Short: "Manage Git project cache",
|
||||
Long: util.CacheCmdLong,
|
||||
}
|
||||
|
||||
var utils *util.Utils
|
||||
|
||||
func runCacheCmd(cmd *cobra.Command, args []string) {
|
||||
utils = util.MustFromCtx(cmd.Context())
|
||||
|
||||
utils.InitProjectCache(cmd, args)
|
||||
utils.Cache().LockCache()
|
||||
}
|
||||
|
||||
func postCacheCmd(cmd *cobra.Command, args []string) {
|
||||
utils.PostProjectCache(cmd, args)
|
||||
utils.Cache().UnlockCache()
|
||||
}
|
||||
|
||||
func init() {
|
||||
CacheCmd.PersistentFlags().Duration("ttl", 48*time.Hour,
|
||||
"Duration before cache is re-built in go time.Duration format")
|
||||
|
||||
viper.BindPFlags(CacheCmd.Flags())
|
||||
|
||||
CacheCmd.AddCommand(clearCmd)
|
||||
CacheCmd.AddCommand(dumpCmd)
|
||||
CacheCmd.AddCommand(loadCmd)
|
||||
CacheCmd.AddCommand(unlockCmd)
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cmd
|
||||
package cache
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
@ -12,7 +12,7 @@ If --clearAliases is provided, will also reset aliases. Use with caution.`
|
||||
|
||||
var clearCmd = &cobra.Command{
|
||||
Use: "clear",
|
||||
Short: "Clear GitLab Project Cache",
|
||||
Short: "Clear Git Project Cache",
|
||||
PreRun: runCacheCmd,
|
||||
PostRun: postCacheCmd,
|
||||
Long: longDesc,
|
||||
@ -21,11 +21,10 @@ var clearCmd = &cobra.Command{
|
||||
|
||||
func clearCache(cmd *cobra.Command, args []string) {
|
||||
slog.Debug("Preparing to clear local cache")
|
||||
projectCache.Clear(conf.Cache.Clear.ClearAliases)
|
||||
utils.Cache().Clear(utils.Config().Cache.Clear.ClearAliases)
|
||||
}
|
||||
|
||||
func init() {
|
||||
cacheCmd.AddCommand(clearCmd)
|
||||
clearCmd.Flags().Bool("clearAliases", false, "Will also clear aliases from the cache, use with caution")
|
||||
viper.BindPFlag("cache.clear.clearAliases", clearCmd.LocalFlags().Lookup("clearAliases"))
|
||||
}
|
15
cmd/cache_dump.go → cmd/cache/cache_dump.go
vendored
15
cmd/cache_dump.go → cmd/cache/cache_dump.go
vendored
@ -1,15 +1,17 @@
|
||||
package cmd
|
||||
package cache
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/util"
|
||||
)
|
||||
|
||||
var dumpCmd = &cobra.Command{
|
||||
Use: "dump",
|
||||
Short: "Dump GitLab project cache",
|
||||
Short: "Dump Git project cache",
|
||||
Long: `Dumps cache to display`,
|
||||
PreRun: runCacheCmd,
|
||||
PostRun: postCacheCmd,
|
||||
@ -17,16 +19,15 @@ var dumpCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
func runCacheDunpCmd(cmd *cobra.Command, args []string) {
|
||||
remotes := viper.GetStringSlice(FlagRemote)
|
||||
if conf.Dump.Full {
|
||||
fmt.Println(projectCache.DumpString(true, searchStringFromArgs(args), remotes...))
|
||||
remotes := viper.GetStringSlice(util.FlagRemote)
|
||||
if utils.Config().Dump.Full {
|
||||
fmt.Println(utils.Cache().DumpString(true, utils.SearchStringFromArgs(args), remotes...))
|
||||
} else {
|
||||
plog.Info(projectCache.String())
|
||||
utils.Logger().Info(utils.Cache().String())
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
cacheCmd.AddCommand(dumpCmd)
|
||||
dumpCmd.PersistentFlags().BoolP("full", "f", false, "Dumps entire cache")
|
||||
viper.BindPFlag("dump.full", dumpCmd.LocalFlags().Lookup("full"))
|
||||
}
|
31
cmd/cache/cache_load.go
vendored
Normal file
31
cmd/cache/cache_load.go
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/util"
|
||||
)
|
||||
|
||||
var loadCmd = &cobra.Command{
|
||||
Use: "load",
|
||||
Short: "Load Git Project Cache",
|
||||
Long: `Used to initialize or update a new Git cache. With thousands
|
||||
of projects, it would be too much work to hit the API every time a user
|
||||
wants to find a new project.`,
|
||||
PreRun: runCacheCmd,
|
||||
PostRun: postCacheCmd,
|
||||
Run: loadCache,
|
||||
}
|
||||
|
||||
func loadCache(cmd *cobra.Command, args []string) {
|
||||
remotes := viper.GetStringSlice(util.FlagRemote)
|
||||
utils.Cache().Refresh(remotes...)
|
||||
}
|
||||
|
||||
func init() {
|
||||
loadCmd.PersistentFlags().Bool(util.FlagOwnerOnly, true,
|
||||
"Only load projects that you are owner of")
|
||||
|
||||
viper.BindPFlag(util.ViperCacheLoadOwnerOnly, loadCmd.Flag(util.FlagOwnerOnly))
|
||||
}
|
33
cmd/cache/cache_unlock.go
vendored
Normal file
33
cmd/cache/cache_unlock.go
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"github.com/pterm/pterm"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/util"
|
||||
)
|
||||
|
||||
var unlockCmd = &cobra.Command{
|
||||
Use: "unlock",
|
||||
Short: "unlock Git project cache",
|
||||
Long: `unlocks cache to display`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
utils = util.MustFromCtx(cmd.Context())
|
||||
utils.InitProjectCache(cmd, args)
|
||||
if viper.GetBool(util.ViperCacheUnlockForce) {
|
||||
utils.Cache().UnlockCache()
|
||||
} else if yes, _ := pterm.DefaultInteractiveConfirm.
|
||||
WithDefaultValue(false).
|
||||
Show("Are you sure you want to manually unlock?"); yes {
|
||||
utils.Cache().UnlockCache()
|
||||
} else {
|
||||
utils.Logger().Error("You failed to confirm cache unlock")
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
unlockCmd.PersistentFlags().BoolP(util.FlagCacheForce, "f", false, "force unlocks cache (don't ask)")
|
||||
viper.BindPFlag(util.ViperCacheUnlockForce, unlockCmd.LocalFlags().Lookup(util.FlagCacheForce))
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
var loadCmd = &cobra.Command{
|
||||
Use: "load",
|
||||
Short: "Load GitLab Project Cache",
|
||||
Long: `Used to initialize or update a new GitLab cache. With thousands
|
||||
of projects, it would be too much work to hit the API every time a user
|
||||
wants to find a new project.`,
|
||||
PreRun: runCacheCmd,
|
||||
PostRun: postCacheCmd,
|
||||
Run: loadCache,
|
||||
}
|
||||
|
||||
func loadCache(cmd *cobra.Command, args []string) {
|
||||
remotes := viper.GetStringSlice(FlagRemote)
|
||||
projectCache.Refresh(remotes...)
|
||||
}
|
||||
|
||||
func init() {
|
||||
cacheCmd.AddCommand(loadCmd)
|
||||
|
||||
loadCmd.PersistentFlags().Bool(FlagOwnerOnly, true,
|
||||
"Only load projects that you are owner of")
|
||||
|
||||
viper.BindPFlag(ViperCacheLoadOwnerOnly, loadCmd.Flag(FlagOwnerOnly))
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/pterm/pterm"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
var unlockCmd = &cobra.Command{
|
||||
Use: "unlock",
|
||||
Short: "unlock GitLab project cache",
|
||||
Long: `unlocks cache to display`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
initProjectCache(cmd, args)
|
||||
if viper.GetBool(ViperCacheUnlockForce) {
|
||||
projectCache.UnlockCache()
|
||||
} else if yes, _ := pterm.DefaultInteractiveConfirm.
|
||||
WithDefaultValue(false).
|
||||
Show("Are you sure you want to manually unlock?"); yes {
|
||||
projectCache.UnlockCache()
|
||||
} else {
|
||||
plog.Error("You failed to confirm cache unlock")
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
cacheCmd.AddCommand(unlockCmd)
|
||||
unlockCmd.PersistentFlags().BoolP(FlagCacheForce, "f", false, "force unlocks cache (don't ask)")
|
||||
viper.BindPFlag(ViperCacheUnlockForce, unlockCmd.LocalFlags().Lookup(FlagCacheForce))
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var configCmd = &cobra.Command{
|
||||
Use: "config",
|
||||
Short: "GitLab Project Manager Configuration",
|
||||
Aliases: []string{"conf"},
|
||||
Long: configCmdLong,
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(configCmd)
|
||||
}
|
26
cmd/config/config.go
Normal file
26
cmd/config/config.go
Normal file
@ -0,0 +1,26 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/util"
|
||||
)
|
||||
|
||||
var ConfigCmd = &cobra.Command{
|
||||
Use: "config",
|
||||
Short: "Git Project Manager Configuration",
|
||||
Aliases: []string{"conf"},
|
||||
Long: util.ConfigCmdLong,
|
||||
PersistentPreRun: configCmdPreRun,
|
||||
}
|
||||
|
||||
var utils *util.Utils
|
||||
|
||||
func configCmdPreRun(cmd *cobra.Command, args []string) {
|
||||
utils = util.MustFromCtx(cmd.Context())
|
||||
}
|
||||
|
||||
func init() {
|
||||
ConfigCmd.AddCommand(configGenerateCmd)
|
||||
ConfigCmd.AddCommand(configShowCmd)
|
||||
}
|
@ -10,15 +10,16 @@ import (
|
||||
"github.com/spf13/viper"
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/config"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/info"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/util"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/config"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/info"
|
||||
)
|
||||
|
||||
var configGenerateCmd = &cobra.Command{
|
||||
Use: "generate",
|
||||
Short: "Generate a default configuration",
|
||||
Aliases: []string{"gen", "new", "default"},
|
||||
Long: configGenCmdLong,
|
||||
Long: util.ConfigGenCmdLong,
|
||||
Run: runConfigGenerateCmd,
|
||||
}
|
||||
|
||||
@ -27,34 +28,34 @@ func runConfigGenerateCmd(cmd *cobra.Command, args []string) {
|
||||
if viper.ConfigFileUsed() != "" {
|
||||
configFile = viper.ConfigFileUsed()
|
||||
} else {
|
||||
configFile = defConfigPath
|
||||
configFile = util.DefConfigPath
|
||||
}
|
||||
|
||||
plog.Debug("Using config file " + configFile)
|
||||
utils.Logger().Debug("Using config file " + configFile)
|
||||
|
||||
configFile, _ = resolvePath(configFile)
|
||||
configFile, _ = util.ResolvePath(configFile)
|
||||
|
||||
newConf := promptConfigSettings(&conf)
|
||||
newConf := promptConfigSettings(utils.Config())
|
||||
|
||||
if write, _ := cmd.Flags().GetBool(FlagWrite); write {
|
||||
if write, _ := cmd.Flags().GetBool(util.FlagWrite); write {
|
||||
write, _ := pterm.DefaultInteractiveContinue.
|
||||
WithDefaultText("Really write config file?").
|
||||
WithOptions([]string{"yes", "no"}).
|
||||
Show()
|
||||
if write != "yes" {
|
||||
plog.Fatal("Aborting config file write")
|
||||
utils.Logger().Fatal("Aborting config file write")
|
||||
}
|
||||
|
||||
writeConfigFile(newConf, configFile)
|
||||
plog.Info("Wrote config to file",
|
||||
plog.Args("file", configFile))
|
||||
utils.Logger().Info("Wrote config to file",
|
||||
utils.Logger().Args("file", configFile))
|
||||
|
||||
} else {
|
||||
var c bytes.Buffer
|
||||
enc := yaml.NewEncoder(&c)
|
||||
enc.SetIndent(2)
|
||||
enc.Encode(newConf)
|
||||
plog.Info("Suggest running with --write or redirect (> " + configFile + ")")
|
||||
utils.Logger().Info("Suggest running with --write or redirect (> " + configFile + ")")
|
||||
fmt.Print(c.String())
|
||||
}
|
||||
}
|
||||
@ -62,11 +63,11 @@ func runConfigGenerateCmd(cmd *cobra.Command, args []string) {
|
||||
func writeConfigFile(c *config.Config, path string) {
|
||||
file, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o640)
|
||||
if err != nil {
|
||||
plog.Error("Failed to prepare config for writing", plog.Args("error", err))
|
||||
utils.Logger().Error("Failed to prepare config for writing", utils.Logger().Args("error", err))
|
||||
}
|
||||
enc := yaml.NewEncoder(file)
|
||||
if err := enc.Encode(c); err != nil {
|
||||
plog.Fatal("Failed writing config file", plog.Args("file", path))
|
||||
utils.Logger().Fatal("Failed writing config file", utils.Logger().Args("file", path))
|
||||
}
|
||||
}
|
||||
|
||||
@ -149,7 +150,6 @@ func promptConfigSettings(c *config.Config) *config.Config {
|
||||
}
|
||||
|
||||
func init() {
|
||||
configCmd.AddCommand(configGenerateCmd)
|
||||
configGenerateCmd.PersistentFlags().Bool(FlagPrompt, false, "Prompt for settings")
|
||||
configGenerateCmd.PersistentFlags().Bool(FlagWrite, false, "Write config to file")
|
||||
configGenerateCmd.PersistentFlags().Bool(util.FlagPrompt, false, "Prompt for settings")
|
||||
configGenerateCmd.PersistentFlags().Bool(util.FlagWrite, false, "Write config to file")
|
||||
}
|
@ -6,26 +6,28 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/util"
|
||||
)
|
||||
|
||||
var configShowCmd = &cobra.Command{
|
||||
Use: "show",
|
||||
Short: "Show GitLab Project Manager Configuration",
|
||||
Short: "Show Git Project Manager Configuration",
|
||||
Aliases: []string{"s", "dump", "cat", "ls"},
|
||||
Run: runConfigShowCmd,
|
||||
}
|
||||
|
||||
func runConfigShowCmd(cmd *cobra.Command, args []string) {
|
||||
c := conf
|
||||
c := *utils.Config()
|
||||
|
||||
showSensitive, _ := cmd.Flags().GetBool(FlagSensitive)
|
||||
showSensitive, _ := cmd.Flags().GetBool(util.FlagSensitive)
|
||||
if !showSensitive {
|
||||
plog.Info("Sensitive fields hidden, do not use unreviewed as config")
|
||||
utils.Logger().Info("Sensitive fields hidden, do not use unreviewed as config")
|
||||
for _, r := range c.Remotes {
|
||||
r.Token = strings.Repeat("*", len(r.Token))
|
||||
}
|
||||
} else {
|
||||
plog.Warn("Displaying sensitive fields!")
|
||||
utils.Logger().Warn("Displaying sensitive fields!")
|
||||
}
|
||||
|
||||
enc := yaml.NewEncoder(os.Stdout)
|
||||
@ -34,6 +36,5 @@ func runConfigShowCmd(cmd *cobra.Command, args []string) {
|
||||
}
|
||||
|
||||
func init() {
|
||||
configCmd.AddCommand(configShowCmd)
|
||||
configShowCmd.Flags().BoolP(FlagSensitive, "s", false, "Set to show sensitive fields")
|
||||
configShowCmd.Flags().BoolP(util.FlagSensitive, "s", false, "Set to show sensitive fields")
|
||||
}
|
62
cmd/docs.go
Normal file
62
cmd/docs.go
Normal file
@ -0,0 +1,62 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/cobra/doc"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/util"
|
||||
)
|
||||
|
||||
var docsCmd = &cobra.Command{
|
||||
Use: "docs",
|
||||
Aliases: []string{"documentation"},
|
||||
Short: "Generate documentation for git-project-manager",
|
||||
Args: cobra.RangeArgs(1, 1),
|
||||
ValidArgs: []string{"md", "man", "yaml"},
|
||||
Run: runDocsCmd,
|
||||
}
|
||||
|
||||
func runDocsCmd(cmd *cobra.Command, args []string) {
|
||||
outDir, err := cmd.Flags().GetString(util.FlagDocsPath)
|
||||
if err != nil {
|
||||
utils.Logger().Error("missing docs path")
|
||||
}
|
||||
|
||||
prepareDocsDir(cmd, outDir)
|
||||
|
||||
switch args[0] {
|
||||
case "md":
|
||||
err = doc.GenMarkdownTree(cmd.Root(), outDir)
|
||||
case "man":
|
||||
err = doc.GenManTree(cmd.Root(), &doc.GenManHeader{
|
||||
Title: "EIA Client",
|
||||
Section: "1",
|
||||
}, outDir)
|
||||
case "yaml":
|
||||
err = doc.GenYamlTree(cmd.Root(), outDir)
|
||||
default:
|
||||
utils.Logger().Error("invalid docs type", utils.Logger().Args("type", args[0]))
|
||||
}
|
||||
|
||||
utils.Logger().Info("docs generation complete", utils.Logger().Args(
|
||||
"type", args[0], "docsDir", outDir, "err", err))
|
||||
}
|
||||
|
||||
func prepareDocsDir(_ *cobra.Command, outDir string) {
|
||||
_, err := os.Stat(outDir)
|
||||
if err != nil {
|
||||
err = os.Mkdir(outDir, 0o755)
|
||||
if err != nil {
|
||||
utils.Logger().Error("failed to create docs path", utils.Logger().Args(
|
||||
"error", err.Error(), "docsDir", outDir))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
docsCmd.PersistentFlags().StringP(util.FlagDocsPath, "d", "./docs", "specify output directory for documentation")
|
||||
|
||||
rootCmd.AddCommand(docsCmd)
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/cache"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/projects"
|
||||
)
|
||||
|
||||
var projectCmd = &cobra.Command{
|
||||
Use: "project [fuzzy alias search]",
|
||||
Short: "Use a GitLab project",
|
||||
Aliases: []string{"proj", "projects", "p"},
|
||||
Args: cobra.MaximumNArgs(1),
|
||||
ArgAliases: []string{"alias"},
|
||||
Long: projCmdLong,
|
||||
PersistentPreRun: initProjectCmd,
|
||||
PersistentPostRun: postProjectCmd,
|
||||
// Run: projectGoCmdRun,
|
||||
}
|
||||
|
||||
func getProject(args []string) *projects.Project {
|
||||
remotes := viper.GetStringSlice(FlagRemote)
|
||||
fzfOpts := &fzfProjectOpts{
|
||||
Ctx: rootCmd.Context(),
|
||||
Search: searchStringFromArgs(args),
|
||||
Remotes: remotes,
|
||||
}
|
||||
project := fzfFindProject(fzfOpts)
|
||||
|
||||
if project == nil {
|
||||
plog.Fatal("Failed to find a project, nothing to do")
|
||||
} else {
|
||||
plog.Debug("Houston, we have a project", plog.Args(
|
||||
"project", project.String(),
|
||||
"aliases", cache.ProjectAliasesString(
|
||||
projectCache.GetProjectAliases(project)),
|
||||
))
|
||||
}
|
||||
|
||||
if len(projectCache.GetProjectAliases(project)) == 0 {
|
||||
plog.Info("New project, set aliases or press enter for default")
|
||||
addNewAliases(project.ID)
|
||||
}
|
||||
|
||||
return project
|
||||
}
|
||||
|
||||
func initProjectCmd(cmd *cobra.Command, args []string) {
|
||||
initProjectCache(cmd, args)
|
||||
mustHaveProjects(cmd, args)
|
||||
}
|
||||
|
||||
func postProjectCmd(cmd *cobra.Command, args []string) {
|
||||
postProjectCache(cmd, args)
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(projectCmd)
|
||||
}
|
||||
|
||||
func mustHaveProjects(cmd *cobra.Command, args []string) {
|
||||
if len(projectCache.Projects) == 0 {
|
||||
plog.Fatal("No projects to " + cmd.Name() + ", try running cache load")
|
||||
}
|
||||
}
|
66
cmd/project/project.go
Normal file
66
cmd/project/project.go
Normal file
@ -0,0 +1,66 @@
|
||||
package project
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/alias"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/util"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/cache"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/projects"
|
||||
)
|
||||
|
||||
var ProjectCmd = &cobra.Command{
|
||||
Use: "project [fuzzy alias search]",
|
||||
Short: "Use a Git project",
|
||||
Aliases: []string{"proj", "projects", "p"},
|
||||
Args: cobra.MaximumNArgs(1),
|
||||
ArgAliases: []string{"alias"},
|
||||
Long: util.ProjCmdLong,
|
||||
PersistentPreRun: projectCmdPreRun,
|
||||
PersistentPostRun: util.PostProjectCmd,
|
||||
// Run: projectGoCmdRun,
|
||||
}
|
||||
|
||||
var utils *util.Utils
|
||||
|
||||
func projectCmdPreRun(cmd *cobra.Command, args []string) {
|
||||
utils = util.MustFromCtx(cmd.Context())
|
||||
util.InitProjects(cmd, args)
|
||||
}
|
||||
|
||||
func getProject(cmd *cobra.Command, args []string) *projects.Project {
|
||||
remotes := viper.GetStringSlice(util.FlagRemote)
|
||||
fzfOpts := &util.FzfProjectOpts{
|
||||
Ctx: cmd.Context(),
|
||||
Search: utils.SearchStringFromArgs(args),
|
||||
Remotes: remotes,
|
||||
}
|
||||
project := utils.FzfFindProject(fzfOpts)
|
||||
|
||||
if project == nil {
|
||||
utils.Logger().Fatal("Failed to find a project, nothing to do")
|
||||
} else {
|
||||
utils.Logger().Debug("Houston, we have a project", utils.Logger().Args(
|
||||
"project", project.String(),
|
||||
"aliases", cache.ProjectAliasesString(
|
||||
utils.Cache().GetProjectAliases(project)),
|
||||
))
|
||||
}
|
||||
|
||||
if len(utils.Cache().GetProjectAliases(project)) == 0 {
|
||||
utils.Logger().Info("New project, set aliases or press enter for default")
|
||||
alias.AddNewAliases(cmd, project.GetID())
|
||||
}
|
||||
|
||||
return project
|
||||
}
|
||||
|
||||
func init() {
|
||||
ProjectCmd.AddCommand(projectAddCmd)
|
||||
ProjectCmd.AddCommand(projectGoCmd)
|
||||
ProjectCmd.AddCommand(projectListCmd)
|
||||
ProjectCmd.AddCommand(projectOpenCmd)
|
||||
ProjectCmd.AddCommand(projectRunCmd)
|
||||
ProjectCmd.AddCommand(projectShowCmd)
|
||||
}
|
@ -1,21 +1,19 @@
|
||||
package cmd
|
||||
package project
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/util"
|
||||
)
|
||||
|
||||
var projectAddCmd = &cobra.Command{
|
||||
Use: "add",
|
||||
Short: "Add a new GitLab project",
|
||||
Short: "Add a new Git project",
|
||||
Aliases: []string{"a", "alias"},
|
||||
Long: projAddCmdLong,
|
||||
Long: util.ProjAddCmdLong,
|
||||
Run: projectAddCmdRun,
|
||||
}
|
||||
|
||||
func projectAddCmdRun(cmd *cobra.Command, args []string) {
|
||||
getProject(args)
|
||||
}
|
||||
|
||||
func init() {
|
||||
projectCmd.AddCommand(projectAddCmd)
|
||||
getProject(cmd, args)
|
||||
}
|
53
cmd/project/project_go.go
Normal file
53
cmd/project/project_go.go
Normal file
@ -0,0 +1,53 @@
|
||||
package project
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/util"
|
||||
)
|
||||
|
||||
var projectGoCmd = &cobra.Command{
|
||||
Use: "go [fuzzy alias search]",
|
||||
Short: "Go to a Git project",
|
||||
Aliases: []string{"goto", "cd"},
|
||||
Args: cobra.MaximumNArgs(1),
|
||||
ArgAliases: []string{"project"},
|
||||
ValidArgsFunction: util.ValidAliasesFunc,
|
||||
Long: util.ProjGoCmdLong,
|
||||
Run: projectGoCmdRun,
|
||||
}
|
||||
|
||||
func projectGoCmdRun(cmd *cobra.Command, args []string) {
|
||||
remotes := viper.GetStringSlice(util.FlagRemote)
|
||||
fzfOpts := &util.FzfProjectOpts{
|
||||
Ctx: cmd.Context(),
|
||||
Search: utils.SearchStringFromArgs(args),
|
||||
MustHaveAlias: true,
|
||||
Remotes: remotes,
|
||||
}
|
||||
project := utils.FzfSearchProjectAliases(fzfOpts)
|
||||
|
||||
if project == nil {
|
||||
utils.Logger().Fatal("No project selected, nowhere to go")
|
||||
}
|
||||
|
||||
utils.Cache().GoTo(project)
|
||||
project.SetRepo(utils.Cache().OpenProject(cmd.Context(), project))
|
||||
|
||||
utils.Logger().Debug("Project ready", utils.Logger().Args(
|
||||
"path", utils.Cache().GetProjectPath(project),
|
||||
"project", project,
|
||||
))
|
||||
|
||||
fmt.Fprintln(os.Stderr, project.GetGitInfo())
|
||||
|
||||
// This should be read by any source command, for instance
|
||||
// `cd "$(git-project-manager projects cd somealias)"`
|
||||
fmt.Println(utils.Cache().GetProjectPath(project))
|
||||
exec.Command("cd", utils.Cache().GetProjectPath(project)).Run()
|
||||
}
|
28
cmd/project/project_list.go
Normal file
28
cmd/project/project_list.go
Normal file
@ -0,0 +1,28 @@
|
||||
package project
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/util"
|
||||
)
|
||||
|
||||
var projectListCmd = &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "List Git Projects",
|
||||
Aliases: []string{"ls", "l"},
|
||||
Long: util.ProjListCmdLong,
|
||||
Run: projectListCmdRun,
|
||||
}
|
||||
|
||||
func projectListCmdRun(cmd *cobra.Command, args []string) {
|
||||
remotes := viper.GetStringSlice(util.FlagRemote)
|
||||
fmt.Println(utils.Cache().DumpString(viper.GetBool(util.ViperProjectListAll), utils.SearchStringFromArgs(args), remotes...))
|
||||
}
|
||||
|
||||
func init() {
|
||||
projectListCmd.PersistentFlags().Bool(util.FlagAll, false, "List all, not just cloned locally")
|
||||
viper.BindPFlag(util.ViperProjectListAll, projectListCmd.Flag(util.FlagAll))
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package cmd
|
||||
package project
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"os"
|
||||
"os/exec"
|
||||
@ -8,6 +9,8 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/util"
|
||||
)
|
||||
|
||||
var projectOpenCmd = &cobra.Command{
|
||||
@ -15,8 +18,8 @@ var projectOpenCmd = &cobra.Command{
|
||||
Short: "Open project in your IDE",
|
||||
Aliases: []string{"goto", "cd"},
|
||||
Args: cobra.OnlyValidArgs,
|
||||
ValidArgsFunction: validAliasesFunc,
|
||||
Long: projOpenCmdLong,
|
||||
ValidArgsFunction: util.ValidAliasesFunc,
|
||||
Long: util.ProjOpenCmdLong,
|
||||
Run: projectOpenCmdRun,
|
||||
}
|
||||
|
||||
@ -48,47 +51,47 @@ func projectOpenCmdRun(cmd *cobra.Command, args []string) {
|
||||
// Find an editor
|
||||
editor := findEditor()
|
||||
if editor == "" {
|
||||
plog.Fatal("No usable editor found")
|
||||
utils.Logger().Fatal("No usable editor found")
|
||||
}
|
||||
|
||||
remotes := viper.GetStringSlice(FlagRemote)
|
||||
fzfOpts := &fzfProjectOpts{
|
||||
remotes := viper.GetStringSlice(util.FlagRemote)
|
||||
fzfOpts := &util.FzfProjectOpts{
|
||||
Ctx: cmd.Context(),
|
||||
Search: searchStringFromArgs(args),
|
||||
Search: utils.SearchStringFromArgs(args),
|
||||
Remotes: remotes,
|
||||
}
|
||||
project := fzfCwdOrSearchProjectAliases(fzfOpts)
|
||||
project := utils.FzfCwdOrSearchProjectAliases(fzfOpts)
|
||||
if project == nil {
|
||||
plog.Fatal("No project to open, nothing to do")
|
||||
utils.Logger().Fatal("No project to open, nothing to do")
|
||||
}
|
||||
|
||||
// Check the project
|
||||
path := projectCache.GetProjectPath(project)
|
||||
path := utils.Cache().GetProjectPath(project)
|
||||
if _, err := os.Stat(path); err != nil {
|
||||
plog.Fatal("Unable to open project", plog.Args("error", err))
|
||||
utils.Logger().Fatal("Unable to open project", utils.Logger().Args("error", err))
|
||||
}
|
||||
|
||||
// Open the project with the editor
|
||||
file := getEntrypointFile(path)
|
||||
openEditor(editor, path+"/"+file)
|
||||
openEditor(cmd.Context(), editor, path+"/"+file)
|
||||
}
|
||||
|
||||
func openEditor(editor string, path string) {
|
||||
func openEditor(ctx context.Context, editor string, path string) {
|
||||
// Compile arguments
|
||||
args := make([]string, 0, 1)
|
||||
if conf.Editor.OpenFlags != "" {
|
||||
args = append(args, conf.Editor.OpenFlags)
|
||||
if utils.Config().Editor.OpenFlags != "" {
|
||||
args = append(args, utils.Config().Editor.OpenFlags)
|
||||
}
|
||||
args = append(args, path)
|
||||
|
||||
// Launch editor
|
||||
cmd := exec.CommandContext(rootCmd.Context(), editor, args...)
|
||||
cmd := exec.CommandContext(ctx, editor, args...)
|
||||
cmd.Dir = filepath.Dir(path)
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
|
||||
if err := cmd.Run(); err != nil {
|
||||
plog.Error("Failed to open project", plog.Args(
|
||||
utils.Logger().Error("Failed to open project", utils.Logger().Args(
|
||||
"error", err.Error(),
|
||||
"command", cmd.String(),
|
||||
))
|
||||
@ -100,7 +103,7 @@ func openEditor(editor string, path string) {
|
||||
func getEntrypointFile(projectPath string) string {
|
||||
if err := os.Chdir(projectPath); err != nil {
|
||||
return ""
|
||||
} else if conf.Editor.OpenDirectory {
|
||||
} else if utils.Config().Editor.OpenDirectory {
|
||||
return "."
|
||||
}
|
||||
|
||||
@ -119,10 +122,10 @@ func findEditor() string {
|
||||
var err error
|
||||
|
||||
// First try configured editor
|
||||
if conf.Editor.Binary != "" {
|
||||
editor, err = getEditor(conf.Editor.Binary)
|
||||
if utils.Config().Editor.Binary != "" {
|
||||
editor, err = getEditor(utils.Config().Editor.Binary)
|
||||
if err != nil || editor == "" {
|
||||
plog.Error("Configured editor is not usable, finding others", plog.Args(
|
||||
utils.Logger().Error("Configured editor is not usable, finding others", utils.Logger().Args(
|
||||
"error", err,
|
||||
))
|
||||
}
|
||||
@ -130,7 +133,7 @@ func findEditor() string {
|
||||
|
||||
// Then try to find a known editor
|
||||
if editor == "" || err != nil {
|
||||
conf.Editor.OpenFlags = ""
|
||||
utils.Config().Editor.OpenFlags = ""
|
||||
for _, e := range knownEditors {
|
||||
path, err := getEditor(e)
|
||||
if err == nil && path != "" {
|
||||
@ -140,9 +143,9 @@ func findEditor() string {
|
||||
}
|
||||
}
|
||||
|
||||
plog.Debug("Editor found for open", plog.Args(
|
||||
utils.Logger().Debug("Editor found for open", utils.Logger().Args(
|
||||
"editor", editor,
|
||||
"command", editor+" "+conf.Editor.OpenFlags,
|
||||
"command", editor+" "+utils.Config().Editor.OpenFlags,
|
||||
))
|
||||
|
||||
return editor
|
||||
@ -152,7 +155,7 @@ func getEditor(editor string) (string, error) {
|
||||
path, err := getEditorPath(editor)
|
||||
if path != "" && err == nil {
|
||||
if !isEditorExecutable(path) {
|
||||
err = errors.New("Editor is not executable")
|
||||
err = errors.New("editor is not executable")
|
||||
}
|
||||
}
|
||||
return path, err
|
||||
@ -164,7 +167,7 @@ func getEditorPath(editor string) (string, error) {
|
||||
editor, _ = exec.LookPath(editor)
|
||||
}
|
||||
|
||||
return resolvePath(editor)
|
||||
return util.ResolvePath(editor)
|
||||
}
|
||||
|
||||
func isEditorExecutable(editor string) bool {
|
||||
@ -180,7 +183,6 @@ func isEditorExecutable(editor string) bool {
|
||||
}
|
||||
|
||||
func init() {
|
||||
projectCmd.AddCommand(projectOpenCmd)
|
||||
projectOpenCmd.PersistentFlags().String("displayName", "", "Set display name of editor (meant for config file)")
|
||||
projectOpenCmd.PersistentFlags().String("binary", "", "Path to editor binary")
|
||||
projectOpenCmd.PersistentFlags().String("openFlags", "", "Optional flags when opening project (e.g. --reuse-window)")
|
@ -1,4 +1,4 @@
|
||||
package cmd
|
||||
package project
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@ -7,35 +7,37 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/util"
|
||||
)
|
||||
|
||||
var projectRunCmd = &cobra.Command{
|
||||
Use: "run",
|
||||
Short: "Run the project (e.g. go run .)",
|
||||
Aliases: []string{"exec", "r"},
|
||||
Long: projRunCmdLong,
|
||||
Long: util.ProjRunCmdLong,
|
||||
Run: projectRunCmdRun,
|
||||
}
|
||||
|
||||
func projectRunCmdRun(cmd *cobra.Command, args []string) {
|
||||
remotes := viper.GetStringSlice(FlagRemote)
|
||||
fzfOpts := &fzfProjectOpts{
|
||||
remotes := viper.GetStringSlice(util.FlagRemote)
|
||||
fzfOpts := &util.FzfProjectOpts{
|
||||
Ctx: cmd.Context(),
|
||||
Search: searchStringFromArgs(args),
|
||||
Search: utils.SearchStringFromArgs(args),
|
||||
Remotes: remotes,
|
||||
}
|
||||
project := fzfCwdOrSearchProjectAliases(fzfOpts)
|
||||
project := utils.FzfCwdOrSearchProjectAliases(fzfOpts)
|
||||
if project == nil {
|
||||
plog.Fatal("No project selected, nothing to open")
|
||||
utils.Logger().Fatal("No project selected, nothing to open")
|
||||
}
|
||||
|
||||
lang := project.GetLanguage()
|
||||
|
||||
if lang == nil {
|
||||
plog.Fatal("GitLab isn't sure what language this project is... can't run.")
|
||||
utils.Logger().Fatal("Git remote isn't sure what language this project is... can't run.")
|
||||
}
|
||||
|
||||
plog.Debug(fmt.Sprintf("Project is written in %s, %.2f%% coverage", lang.Name, lang.Percentage))
|
||||
utils.Logger().Debug(fmt.Sprintf("Project is written in %s, %.2f%% coverage", lang.Name, lang.Percentage))
|
||||
|
||||
switch lang.Name {
|
||||
case "Go":
|
||||
@ -50,5 +52,5 @@ func projectRunCmdRun(cmd *cobra.Command, args []string) {
|
||||
}
|
||||
|
||||
func init() {
|
||||
projectCmd.AddCommand(projectRunCmd)
|
||||
ProjectCmd.AddCommand(projectRunCmd)
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cmd
|
||||
package project
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@ -8,15 +8,16 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/projects"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/util"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/projects"
|
||||
)
|
||||
|
||||
var projectShowCmd = &cobra.Command{
|
||||
Use: "show [fuzzy alias search]",
|
||||
Short: "Show detail for a GitLab project",
|
||||
Short: "Show detail for a Git project",
|
||||
Aliases: []string{"cat", "s"},
|
||||
Args: cobra.ArbitraryArgs,
|
||||
Long: projShowCmdLong,
|
||||
Long: util.ProjShowCmdLong,
|
||||
Run: projectShowCmdRun,
|
||||
}
|
||||
|
||||
@ -24,24 +25,24 @@ func projectShowCmdRun(cmd *cobra.Command, args []string) {
|
||||
var project *projects.Project
|
||||
var inCwd bool
|
||||
|
||||
remotes := viper.GetStringSlice(FlagRemote)
|
||||
fzfOpts := &fzfProjectOpts{
|
||||
remotes := viper.GetStringSlice(util.FlagRemote)
|
||||
fzfOpts := &util.FzfProjectOpts{
|
||||
Ctx: cmd.Context(),
|
||||
Search: searchStringFromArgs(args),
|
||||
Search: utils.SearchStringFromArgs(args),
|
||||
Remotes: remotes,
|
||||
}
|
||||
|
||||
// Try to find project from current directory
|
||||
if viper.GetBool(ViperProjectShowCurrent) {
|
||||
if viper.GetBool(util.ViperProjectShowCurrent) {
|
||||
var err error
|
||||
project, err = projectCache.GetProjectFromCwd()
|
||||
project, err = utils.Cache().GetProjectFromCwd()
|
||||
if err != nil {
|
||||
// Not an error because we're still going to try to find a project
|
||||
plog.Warn("Failed to get project from current directory", plog.Args(
|
||||
utils.Logger().Warn("Failed to get project from current directory", utils.Logger().Args(
|
||||
"error", err,
|
||||
))
|
||||
} else if project == nil {
|
||||
plog.Warn("Failed to use --current flag, project not found in current path")
|
||||
utils.Logger().Warn("Failed to use --current flag, project not found in current path")
|
||||
} else {
|
||||
inCwd = true
|
||||
}
|
||||
@ -49,15 +50,15 @@ func projectShowCmdRun(cmd *cobra.Command, args []string) {
|
||||
|
||||
// Otherwise find from the given search string
|
||||
if project == nil {
|
||||
project = fzfFindProject(fzfOpts)
|
||||
project = utils.FzfFindProject(fzfOpts)
|
||||
}
|
||||
|
||||
// Do a full fuzzy find if all else fails
|
||||
if project == nil {
|
||||
var err error
|
||||
project, err = fzfProject(fzfOpts)
|
||||
project, err = utils.FzfProject(fzfOpts)
|
||||
if err != nil || project == nil {
|
||||
plog.Fatal("Failed to find project, nothing to show", plog.Args(
|
||||
utils.Logger().Fatal("Failed to find project, nothing to show", utils.Logger().Args(
|
||||
"error", err,
|
||||
))
|
||||
}
|
||||
@ -68,17 +69,17 @@ func projectShowCmdRun(cmd *cobra.Command, args []string) {
|
||||
WithLeftPadding(5).WithRightPadding(5).
|
||||
WithBoxStyle(&pterm.Style{pterm.FgLightBlue}).
|
||||
WithTitle(pterm.Bold.Sprint(pterm.LightGreen("Project Information"))).
|
||||
Println(projectCache.ProjectString(project))
|
||||
Println(utils.Cache().ProjectString(project))
|
||||
fmt.Println()
|
||||
|
||||
if inCwd {
|
||||
project.SetRepo(projectCache.OpenProject(cmd.Context(), project))
|
||||
project.SetRepo(utils.Cache().OpenProject(cmd.Context(), project))
|
||||
fmt.Fprintln(os.Stderr, project.GetGitInfo()+"\n")
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
projectCmd.AddCommand(projectShowCmd)
|
||||
projectShowCmd.PersistentFlags().Bool(FlagCurrent, false, "Use project in CWD rather than fuzzy find")
|
||||
viper.BindPFlag(ViperProjectShowCurrent, projectShowCmd.Flag(FlagCurrent))
|
||||
ProjectCmd.AddCommand(projectShowCmd)
|
||||
projectShowCmd.PersistentFlags().Bool(util.FlagCurrent, false, "Use project in CWD rather than fuzzy find")
|
||||
viper.BindPFlag(util.ViperProjectShowCurrent, projectShowCmd.Flag(util.FlagCurrent))
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
var projectGoCmd = &cobra.Command{
|
||||
Use: "go [fuzzy alias search]",
|
||||
Short: "Go to a GitLab project",
|
||||
Aliases: []string{"goto", "cd"},
|
||||
Args: cobra.MaximumNArgs(1),
|
||||
ArgAliases: []string{"project"},
|
||||
ValidArgsFunction: validAliasesFunc,
|
||||
Long: projGoCmdLong,
|
||||
Run: projectGoCmdRun,
|
||||
}
|
||||
|
||||
func projectGoCmdRun(cmd *cobra.Command, args []string) {
|
||||
remotes := viper.GetStringSlice(FlagRemote)
|
||||
fzfOpts := &fzfProjectOpts{
|
||||
Ctx: cmd.Context(),
|
||||
Search: searchStringFromArgs(args),
|
||||
MustHaveAlias: true,
|
||||
Remotes: remotes,
|
||||
}
|
||||
project := fzfSearchProjectAliases(fzfOpts)
|
||||
|
||||
if project == nil {
|
||||
plog.Fatal("No project selected, nowhere to go")
|
||||
}
|
||||
|
||||
projectCache.GoTo(project)
|
||||
project.SetRepo(projectCache.OpenProject(cmd.Context(), project))
|
||||
|
||||
plog.Debug("Project ready", plog.Args(
|
||||
"path", projectCache.GetProjectPath(project),
|
||||
"project", project,
|
||||
))
|
||||
|
||||
fmt.Fprintln(os.Stderr, project.GetGitInfo())
|
||||
|
||||
// This should be read by any source command, for instance
|
||||
// `cd "$(gitlab-project-manager projects cd somealias)"`
|
||||
fmt.Println(projectCache.GetProjectPath(project))
|
||||
exec.Command("cd", projectCache.GetProjectPath(project)).Run()
|
||||
}
|
||||
|
||||
func init() {
|
||||
projectCmd.AddCommand(projectGoCmd)
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
var projectListCmd = &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "List GitLab Projects",
|
||||
Aliases: []string{"ls", "l"},
|
||||
Long: projListCmdLong,
|
||||
Run: projectListCmdRun,
|
||||
}
|
||||
|
||||
func projectListCmdRun(cmd *cobra.Command, args []string) {
|
||||
remotes := viper.GetStringSlice(FlagRemote)
|
||||
fmt.Println(projectCache.DumpString(viper.GetBool(ViperProjectListAll), searchStringFromArgs(args), remotes...))
|
||||
}
|
||||
|
||||
func init() {
|
||||
projectCmd.AddCommand(projectListCmd)
|
||||
projectListCmd.PersistentFlags().Bool(FlagAll, false, "List all, not just cloned locally")
|
||||
viper.BindPFlag(ViperProjectListAll, projectListCmd.Flag(FlagAll))
|
||||
}
|
103
cmd/root.go
103
cmd/root.go
@ -4,32 +4,42 @@ import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
|
||||
"github.com/pterm/pterm"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/config"
|
||||
)
|
||||
|
||||
var (
|
||||
conf config.Config
|
||||
plog *pterm.Logger
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/alias"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/cache"
|
||||
conf "gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/config"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/project"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/cmd/util"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/config"
|
||||
)
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "gitlab-project-manager",
|
||||
Use: "git-project-manager",
|
||||
Aliases: []string{"gpm"},
|
||||
Short: "Find and use GitLab projects locally",
|
||||
Long: rootCmdLong,
|
||||
Short: "Find and use Git projects locally",
|
||||
Long: util.RootCmdLong,
|
||||
PersistentPreRun: initRootCmd,
|
||||
}
|
||||
|
||||
var (
|
||||
Version = "development"
|
||||
configExemptCommands = regexp.MustCompile(`^(doc|conf)`)
|
||||
utils *util.Utils
|
||||
)
|
||||
|
||||
// Hook traversal is enabled, so this will be run for all
|
||||
// sub-commands regardless of their registered pre-hooks
|
||||
func initRootCmd(cmd *cobra.Command, args []string) {
|
||||
initProjectPath(cmd, args)
|
||||
cmd.SetContext(util.AddToCtx(cmd.Context(), utils))
|
||||
utils.InitProjectPath(cmd, args)
|
||||
}
|
||||
|
||||
// Execute adds all child commands to the root command and sets flags appropriately.
|
||||
@ -40,35 +50,47 @@ func Execute() {
|
||||
|
||||
err := rootCmd.ExecuteContext(ctx)
|
||||
if err != nil {
|
||||
pterm.Error.Printfln(pterm.LightYellow("Command failed, " + err.Error()))
|
||||
pterm.Error.Printfln("%s", pterm.LightYellow("Command failed, "+err.Error()))
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
cobra.EnableTraverseRunHooks = true
|
||||
cobra.OnInitialize(initConfig)
|
||||
|
||||
utils = &util.Utils{}
|
||||
cobra.OnInitialize(getInitConfigFunc(utils))
|
||||
|
||||
// Global flags
|
||||
rootCmd.PersistentFlags().String(FlagConfig, "",
|
||||
"config file (default is "+defConfigPath+")")
|
||||
rootCmd.PersistentFlags().String(FlagPath, "",
|
||||
rootCmd.PersistentFlags().String(util.FlagConfig, "",
|
||||
"config file (default is "+util.DefConfigPath+")")
|
||||
rootCmd.PersistentFlags().String(util.FlagPath, "",
|
||||
"Sets a path for local clones of projects")
|
||||
rootCmd.PersistentFlags().String(FlagLogLevel, defLogLevel,
|
||||
rootCmd.PersistentFlags().String(util.FlagLogLevel, util.DefLogLevel,
|
||||
"Default log level -- info, warn, error, debug")
|
||||
rootCmd.PersistentFlags().StringSlice(FlagRemote, []string{},
|
||||
rootCmd.PersistentFlags().StringSlice(util.FlagRemote, []string{},
|
||||
"Specify remotes by host for any sub-command. Provide multiple times or comma delimited.")
|
||||
|
||||
// Flag autocompletion
|
||||
rootCmd.RegisterFlagCompletionFunc(FlagLogLevel, validLogLevelsFunc)
|
||||
rootCmd.RegisterFlagCompletionFunc(FlagRemote, validRemotesFunc)
|
||||
|
||||
viper.BindPFlags(rootCmd.PersistentFlags())
|
||||
|
||||
// Flag autocompletion
|
||||
rootCmd.RegisterFlagCompletionFunc(util.FlagLogLevel, util.ValidLogLevelsFunc)
|
||||
rootCmd.RegisterFlagCompletionFunc(util.FlagRemote, util.ValidRemotesFunc)
|
||||
|
||||
// Subcommands
|
||||
rootCmd.AddCommand(alias.AliasCmd)
|
||||
rootCmd.AddCommand(cache.CacheCmd)
|
||||
rootCmd.AddCommand(conf.ConfigCmd)
|
||||
rootCmd.AddCommand(project.ProjectCmd)
|
||||
|
||||
// Version
|
||||
rootCmd.Version = getVersion()
|
||||
}
|
||||
|
||||
// initConfig reads in config file and ENV variables if set.
|
||||
func initConfig() {
|
||||
cfgFile := viper.GetString(FlagConfig)
|
||||
func getInitConfigFunc(utils *util.Utils) func() {
|
||||
return func() {
|
||||
cfgFile := viper.GetString(util.FlagConfig)
|
||||
if cfgFile != "" {
|
||||
// Use config file from the flag.
|
||||
viper.SetConfigFile(cfgFile)
|
||||
@ -77,42 +99,48 @@ func initConfig() {
|
||||
home, err := os.UserHomeDir()
|
||||
cobra.CheckErr(err)
|
||||
|
||||
// Search config in home directory with name ".gitlab-project-manager" (without extension).
|
||||
viper.AddConfigPath(home + "/.config")
|
||||
// Search config in home directory with name ".git-project-manager" (without extension).
|
||||
configPath := filepath.Join(home, ".config")
|
||||
viper.AddConfigPath(configPath)
|
||||
viper.SetConfigType("yaml")
|
||||
viper.SetConfigName("gitlab-project-manager")
|
||||
viper.SetConfigName(util.GetConfigName(configPath))
|
||||
}
|
||||
|
||||
viper.AutomaticEnv()
|
||||
viper.ReadInConfig()
|
||||
|
||||
// Configure pretty logger
|
||||
plog = pterm.DefaultLogger.
|
||||
WithLevel(getPtermLogLevel(viper.GetString(FlagLogLevel))).
|
||||
plog := pterm.DefaultLogger.
|
||||
WithLevel(getPtermLogLevel(viper.GetString(util.FlagLogLevel))).
|
||||
WithWriter(os.Stderr)
|
||||
if plog.Level == pterm.LogLevelDebug {
|
||||
pterm.EnableDebugMessages()
|
||||
}
|
||||
utils.SetLogger(plog)
|
||||
|
||||
// Load into struct to not be so darn pythonic, retrieving
|
||||
// settings by untyped string "name"
|
||||
conf := new(config.Config)
|
||||
if err := viper.Unmarshal(&conf); err != nil {
|
||||
plog.Error("Failed loading config", plog.Args("err", err))
|
||||
}
|
||||
|
||||
if len(os.Args) > 0 && strings.HasPrefix(os.Args[1], "conf") {
|
||||
utils.SetConfig(conf)
|
||||
|
||||
if len(os.Args) > 0 && configExemptCommands.Match([]byte(os.Args[1])) {
|
||||
plog.Debug("Permitting missing config for config sub-command")
|
||||
return
|
||||
} else if conf.ProjectPath == "" {
|
||||
plog.Fatal("Minimal configuration missing, must have projectPath", plog.Args(
|
||||
"do",
|
||||
"Try running `gitlab-project-manager config default > "+defConfigPath,
|
||||
"Try running `git-project-manager config default > "+util.DefConfigPath,
|
||||
))
|
||||
}
|
||||
|
||||
checkConfigPerms(viper.ConfigFileUsed()) // Abort on world-readable config
|
||||
|
||||
plog.Debug("Configuration loaded", plog.Args("conf", conf))
|
||||
utils.Logger().Debug("Configuration loaded", plog.Args("conf", conf))
|
||||
}
|
||||
}
|
||||
|
||||
func getPtermLogLevel(level string) pterm.LogLevel {
|
||||
@ -136,12 +164,19 @@ func getPtermLogLevel(level string) pterm.LogLevel {
|
||||
func checkConfigPerms(file string) {
|
||||
stat, err := os.Stat(file)
|
||||
if err != nil {
|
||||
plog.Error("Failure reading configuration", plog.Args("err", err))
|
||||
utils.Logger().Error("Failure reading configuration", utils.Logger().Args("err", err))
|
||||
return
|
||||
}
|
||||
if stat.Mode().Perm()&0o004 == 0o004 {
|
||||
plog.Error("Configuration is world-readable. Recomment 0400.",
|
||||
plog.Args("mode", stat.Mode().String()))
|
||||
utils.Logger().Error("Configuration is world-readable. Recomment 0400.",
|
||||
utils.Logger().Args("mode", stat.Mode().String()))
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func getVersion() string {
|
||||
if info, ok := debug.ReadBuildInfo(); ok && info.Main.Version != "(devel)" {
|
||||
return info.Main.Version
|
||||
}
|
||||
return Version
|
||||
}
|
||||
|
121
cmd/util/util.go
Normal file
121
cmd/util/util.go
Normal file
@ -0,0 +1,121 @@
|
||||
// Common utilities used by various subcommands
|
||||
package util
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"sync"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/cache"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/config"
|
||||
"github.com/pterm/pterm"
|
||||
)
|
||||
|
||||
type Utils struct {
|
||||
ctx context.Context
|
||||
config *config.Config
|
||||
logger *pterm.Logger
|
||||
cache *cache.Cache
|
||||
sync.RWMutex
|
||||
}
|
||||
|
||||
type UtilOpts struct {
|
||||
Ctx context.Context
|
||||
Config *config.Config
|
||||
Logger *pterm.Logger
|
||||
Cache *cache.Cache
|
||||
}
|
||||
|
||||
type utilsCtxKey uint8
|
||||
|
||||
const UtilsKey utilsCtxKey = iota
|
||||
|
||||
func AddToCtx(ctx context.Context, u *Utils) context.Context {
|
||||
return context.WithValue(ctx, UtilsKey, u)
|
||||
}
|
||||
|
||||
func MustFromCtx(ctx context.Context) *Utils {
|
||||
utils, err := FromCtx(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return utils
|
||||
}
|
||||
|
||||
func FromCtx(ctx context.Context) (*Utils, error) {
|
||||
utils, avail := ctx.Value(UtilsKey).(*Utils)
|
||||
if !avail {
|
||||
return nil, errors.New("invalid util in context")
|
||||
} else if utils == nil {
|
||||
return nil, errors.New("util never set in context")
|
||||
}
|
||||
|
||||
return utils, nil
|
||||
}
|
||||
|
||||
func (u *Utils) Init(opts *UtilOpts) {
|
||||
u.ctx = opts.Ctx
|
||||
u.SetConfig(opts.Config)
|
||||
u.SetLogger(opts.Logger)
|
||||
u.SetCache(opts.Cache)
|
||||
}
|
||||
|
||||
func (u *Utils) SetCache(c *cache.Cache) {
|
||||
if c == nil {
|
||||
return
|
||||
}
|
||||
|
||||
u.Lock()
|
||||
defer u.Unlock()
|
||||
u.cache = c
|
||||
}
|
||||
|
||||
func (u *Utils) Cache() *cache.Cache {
|
||||
u.RLock()
|
||||
defer u.RUnlock()
|
||||
return u.cache
|
||||
}
|
||||
|
||||
func (u *Utils) SetLogger(l *pterm.Logger) {
|
||||
if l == nil {
|
||||
return
|
||||
}
|
||||
|
||||
u.Lock()
|
||||
defer u.Unlock()
|
||||
u.logger = l
|
||||
}
|
||||
|
||||
func (u *Utils) Logger() *pterm.Logger {
|
||||
u.RLock()
|
||||
defer u.RUnlock()
|
||||
return u.logger
|
||||
}
|
||||
|
||||
func (u *Utils) SetConfig(conf *config.Config) {
|
||||
if conf == nil {
|
||||
return
|
||||
}
|
||||
|
||||
u.Lock()
|
||||
defer u.Unlock()
|
||||
u.config = conf
|
||||
}
|
||||
|
||||
func (u *Utils) Config() *config.Config {
|
||||
u.RLock()
|
||||
defer u.RUnlock()
|
||||
return u.config
|
||||
}
|
||||
|
||||
func (u *Utils) SetContext(c context.Context) {
|
||||
u.Lock()
|
||||
defer u.Unlock()
|
||||
u.ctx = c
|
||||
}
|
||||
|
||||
func (u *Utils) Context() context.Context {
|
||||
u.RLock()
|
||||
defer u.RUnlock()
|
||||
return u.ctx
|
||||
}
|
74
cmd/util/util_completion.go
Normal file
74
cmd/util/util_completion.go
Normal file
@ -0,0 +1,74 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
func ValidProjectsFunc(cmd *cobra.Command, args []string, toComplete string) (
|
||||
[]string, cobra.ShellCompDirective,
|
||||
) {
|
||||
u := MustFromCtx(cmd.Context())
|
||||
u.InitProjectCache(cmd, args)
|
||||
return u.Cache().ProjectStrings(toComplete), cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
|
||||
func ValidAliasesFunc(cmd *cobra.Command, args []string, toComplete string) (
|
||||
[]string, cobra.ShellCompDirective,
|
||||
) {
|
||||
utils := MustFromCtx(cmd.Context())
|
||||
utils.InitProjectCache(cmd, args)
|
||||
return utils.Cache().AliasStrings(toComplete), cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
|
||||
func (u *Utils) ValidProjectsOrAliasesFunc(cmd *cobra.Command, args []string, toComplete string) (
|
||||
[]string, cobra.ShellCompDirective,
|
||||
) {
|
||||
projectStrings, _ := ValidAliasesFunc(cmd, args, toComplete)
|
||||
aliasStrings, _ := ValidProjectsFunc(cmd, args, toComplete)
|
||||
return append(projectStrings, aliasStrings...), cobra.ShellCompDirectiveDefault
|
||||
}
|
||||
|
||||
func ValidRemotesFunc(cmd *cobra.Command, _ []string, toComplete string) (
|
||||
[]string, cobra.ShellCompDirective,
|
||||
) {
|
||||
u := MustFromCtx(cmd.Context())
|
||||
remotes := make([]string, 0, len(u.Config().Remotes))
|
||||
for _, remote := range u.Config().Remotes {
|
||||
if strings.HasPrefix(remote.Host, toComplete) {
|
||||
remotes = append(remotes, remote.Host)
|
||||
}
|
||||
}
|
||||
return remotes, cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
|
||||
func ValidLogLevelsFunc(_ *cobra.Command, _ []string, toComplete string) (
|
||||
[]string, cobra.ShellCompDirective,
|
||||
) {
|
||||
levels := []string{"info", "warn", "error", "debug"}
|
||||
matchingLevels := make([]string, 0, len(levels))
|
||||
for _, level := range levels {
|
||||
if strings.HasPrefix(level, toComplete) {
|
||||
matchingLevels = append(matchingLevels, level)
|
||||
}
|
||||
}
|
||||
return matchingLevels, cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
|
||||
func ValidProjectIdFunc(cmd *cobra.Command, args []string, toComplete string) (
|
||||
[]string, cobra.ShellCompDirective,
|
||||
) {
|
||||
u := MustFromCtx(cmd.Context())
|
||||
u.InitProjectCache(cmd, args)
|
||||
matchingIds := make([]string, 0, len(u.Cache().Projects))
|
||||
for _, p := range u.Cache().Projects {
|
||||
idString := strconv.FormatInt(int64(p.ID), 10)
|
||||
if strings.HasPrefix(idString, toComplete) {
|
||||
matchingIds = append(matchingIds, idString)
|
||||
}
|
||||
}
|
||||
return slices.Clip(matchingIds), cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cmd
|
||||
package util
|
||||
|
||||
const (
|
||||
// Cobra Flags
|
||||
@ -14,6 +14,7 @@ const (
|
||||
FlagPrompt = "prompt"
|
||||
FlagWrite = "write"
|
||||
FlagSensitive = "sensitive"
|
||||
FlagDocsPath = "docsPath"
|
||||
|
||||
// Viper config bindings
|
||||
ViperAliasAddPID = "alias.add.projectID"
|
||||
@ -24,60 +25,62 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
defGitlabHost = "https://gitlab.com"
|
||||
defLogLevel = "info"
|
||||
defConfigPath = "~/.config/gitlab-project-manager.yaml"
|
||||
DefGitlabHost = "https://gitlab.com"
|
||||
DefLogLevel = "info"
|
||||
DefConfigPath = "~/.config/git-project-manager.yaml"
|
||||
ConfigName = "git-project-manager"
|
||||
LegacyConfigName = "gitlab-project-manager"
|
||||
)
|
||||
|
||||
const aliasCmdLong = `Manages project aliases, with options for
|
||||
const AliasCmdLong = `Manages project aliases, with options for
|
||||
listing, adding, and deleting.`
|
||||
|
||||
const aliasListCmdLong = `Lists all aliases by project`
|
||||
const AliasListCmdLong = `Lists all aliases by project`
|
||||
|
||||
const aliasAddCmdLong = `Adds a project alias to a project
|
||||
const AliasAddCmdLong = `Adds a project alias to a project
|
||||
project ID can be provided, or will otherwise use fuzzy find`
|
||||
|
||||
const aliasDeleteCmdLong = `Deletes aliases from projects
|
||||
const AliasDeleteCmdLong = `Deletes aliases from projects
|
||||
project ID can be provided, or will otherwise use fuzzy find`
|
||||
|
||||
const cacheCmdLong = `Contains sub-commands for managing project cache.
|
||||
The project cache keeps this speedy, without smashing against the GitLab
|
||||
const CacheCmdLong = `Contains sub-commands for managing project cache.
|
||||
The project cache keeps this speedy, without smashing against the Git
|
||||
API every time a new project is added / searched for`
|
||||
|
||||
const rootCmdLong = `Finds GitLab projects using fuzzy-find, remembering
|
||||
const RootCmdLong = `Finds Git projects using fuzzy-find, remembering
|
||||
your chosen term for the project as an alias, and offers helpful
|
||||
shortcuts for moving around in projects and opening your code`
|
||||
|
||||
const projCmdLong = `Switches to a GitLab project by name or alias
|
||||
const ProjCmdLong = `Switches to a Git project by name or alias
|
||||
If not found, will enter fzf mode. If not cloned, will clone
|
||||
the project locally.`
|
||||
|
||||
const projGoCmdLong = `Go to a project, searching by alias
|
||||
const ProjGoCmdLong = `Go to a project, searching by alias
|
||||
If project is not already cloned, its path will be built and it
|
||||
will be cloned from source control.
|
||||
|
||||
If conf.projects.alwaysPull, a git pull will be ran automatically`
|
||||
|
||||
const projRunCmdLong = `Runs the current project. Tries to detect
|
||||
const ProjRunCmdLong = `Runs the current project. Tries to detect
|
||||
the language and runs accordingly (e.g. go run .)`
|
||||
|
||||
const projListCmdLong = `List locally cloned projects. Optionally
|
||||
const ProjListCmdLong = `List locally cloned projects. Optionally
|
||||
lists all projects in project cache`
|
||||
|
||||
const projAddCmdLong = `Adds a new project to the local project path
|
||||
const ProjAddCmdLong = `Adds a new project to the local project path
|
||||
uses fuzzy find to locate the project`
|
||||
|
||||
const projShowCmdLong = `Shows detail for a particular project
|
||||
const ProjShowCmdLong = `Shows detail for a particular project
|
||||
Will always fuzzy find`
|
||||
|
||||
const projOpenCmdLong = `Opens the given project directory in the editor
|
||||
const ProjOpenCmdLong = `Opens the given project directory in the editor
|
||||
of your choice. Will find certain well-known entrypoints (e.g. main.go).
|
||||
|
||||
If your editor is set in your config file, it will be used, otherwise
|
||||
one will be found in your path from a list of known defaults.`
|
||||
|
||||
const configCmdLong = `Commands for managing configuration, particulary
|
||||
const ConfigCmdLong = `Commands for managing configuration, particulary
|
||||
useful for seeding a new config file`
|
||||
|
||||
const configGenCmdLong = `Produces yaml to stdout that can be used
|
||||
const ConfigGenCmdLong = `Produces yaml to stdout that can be used
|
||||
to seed the configuration file`
|
@ -1,4 +1,4 @@
|
||||
package cmd
|
||||
package util
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -6,11 +6,11 @@ import (
|
||||
fzf "github.com/ktr0731/go-fuzzyfinder"
|
||||
"golang.org/x/exp/slices"
|
||||
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/cache"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/projects"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/cache"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/projects"
|
||||
)
|
||||
|
||||
type fzfProjectOpts struct {
|
||||
type FzfProjectOpts struct {
|
||||
Ctx context.Context
|
||||
Search string
|
||||
MustHaveAlias bool
|
||||
@ -19,14 +19,14 @@ type fzfProjectOpts struct {
|
||||
|
||||
// This will try to find a project by alias if a search term
|
||||
// is given, otherwise will fuzzy find by project
|
||||
func fzfFindProject(opts *fzfProjectOpts) *projects.Project {
|
||||
func (u *Utils) FzfFindProject(opts *FzfProjectOpts) *projects.Project {
|
||||
var project *projects.Project
|
||||
|
||||
if opts.Search != "" {
|
||||
project = fzfSearchProjectAliases(opts)
|
||||
project = u.FzfSearchProjectAliases(opts)
|
||||
} else {
|
||||
var err error
|
||||
project, err = fzfProject(opts)
|
||||
project, err = u.FzfProject(opts)
|
||||
if project == nil || err != nil {
|
||||
return nil
|
||||
}
|
||||
@ -38,35 +38,35 @@ func fzfFindProject(opts *fzfProjectOpts) *projects.Project {
|
||||
// If . is given as a project, will open project from the
|
||||
// current working directory. Otherwise, will attempt to fuzzy-find
|
||||
// a project given a search term if provided
|
||||
func fzfCwdOrSearchProjectAliases(opts *fzfProjectOpts) *projects.Project {
|
||||
func (u *Utils) FzfCwdOrSearchProjectAliases(opts *FzfProjectOpts) *projects.Project {
|
||||
var project *projects.Project
|
||||
if opts.Search == "." {
|
||||
project, _ = projectCache.GetProjectFromCwd()
|
||||
project, _ = u.Cache().GetProjectFromCwd()
|
||||
} else {
|
||||
project = fzfSearchProjectAliases(opts)
|
||||
project = u.FzfSearchProjectAliases(opts)
|
||||
}
|
||||
return project
|
||||
}
|
||||
|
||||
// This will fuzzy search only aliases, preferring an exact
|
||||
// match if one is given
|
||||
func fzfSearchProjectAliases(opts *fzfProjectOpts) *projects.Project {
|
||||
func (u *Utils) FzfSearchProjectAliases(opts *FzfProjectOpts) *projects.Project {
|
||||
var project *projects.Project
|
||||
var alias *cache.ProjectAlias
|
||||
if alias = projectCache.GetAliasByName(opts.Search, opts.Remotes...); alias != nil {
|
||||
project = projectCache.GetProjectByAlias(alias)
|
||||
plog.Info("Perfect alias match... flawless")
|
||||
if alias = u.Cache().GetAliasByName(opts.Search, opts.Remotes...); alias != nil {
|
||||
project = u.Cache().GetProjectByAlias(alias)
|
||||
u.Logger().Info("Perfect alias match... flawless")
|
||||
} else {
|
||||
// Get fuzzy if we don't have an exact match
|
||||
aliases := projectCache.FuzzyFindAlias(opts.Search)
|
||||
aliases := u.Cache().FuzzyFindAlias(opts.Search)
|
||||
if len(aliases) > 1 {
|
||||
// If multiple aliases were found, switch over to project
|
||||
// by alias mode with merging
|
||||
// alias = fzfAliasFromAliases(rootCmd.Context(), aliases)
|
||||
project, _ = fzfProjectFromAliases(opts, aliases)
|
||||
project, _ = u.FzfProjectFromAliases(opts, aliases)
|
||||
} else if len(aliases) == 1 {
|
||||
alias = aliases[0]
|
||||
project = projectCache.GetProjectByAlias(alias)
|
||||
project = u.Cache().GetProjectByAlias(alias)
|
||||
}
|
||||
}
|
||||
return project
|
||||
@ -76,18 +76,18 @@ func fzfSearchProjectAliases(opts *fzfProjectOpts) *projects.Project {
|
||||
// a single one. Replaced by fzfProjectFromAliases in fzfSearchProjectAliases
|
||||
// as merging is preferred, but can be used if it's ever desirable to
|
||||
// return a single alias from all aliases
|
||||
func fzfAliasFromAliases(opts *fzfProjectOpts, aliases []*cache.ProjectAlias) *cache.ProjectAlias {
|
||||
func (u *Utils) FzfAliasFromAliases(opts *FzfProjectOpts, aliases []*cache.ProjectAlias) *cache.ProjectAlias {
|
||||
var alias *cache.ProjectAlias
|
||||
i, err := fzf.Find(
|
||||
aliases,
|
||||
func(i int) string {
|
||||
return aliases[i].Alias + " -> " + projectCache.GetProjectByAlias(aliases[i]).PathWithNamespace
|
||||
return aliases[i].Alias + " -> " + u.Cache().GetProjectByAlias(aliases[i]).PathWithNamespace
|
||||
},
|
||||
fzf.WithContext(opts.Ctx),
|
||||
fzf.WithHeader("Choose an Alias"),
|
||||
)
|
||||
if err != nil {
|
||||
plog.Error("Failed to fzf alias slice", plog.Args("error", err))
|
||||
u.Logger().Error("Failed to fzf alias slice", u.Logger().Args("error", err))
|
||||
} else {
|
||||
alias = aliases[i]
|
||||
}
|
||||
@ -96,21 +96,21 @@ func fzfAliasFromAliases(opts *fzfProjectOpts, aliases []*cache.ProjectAlias) *c
|
||||
|
||||
// Given a list of aliases, merge them together and use the resulting
|
||||
// list of projects to return a project
|
||||
func fzfProjectFromAliases(opts *fzfProjectOpts, aliases []*cache.ProjectAlias) (
|
||||
func (u *Utils) FzfProjectFromAliases(opts *FzfProjectOpts, aliases []*cache.ProjectAlias) (
|
||||
*projects.Project, error,
|
||||
) {
|
||||
mergedProjects := projectsFromAliases(aliases)
|
||||
mergedProjects := u.projectsFromAliases(aliases)
|
||||
if len(mergedProjects) == 1 {
|
||||
return mergedProjects[0], nil
|
||||
}
|
||||
return fzfProjectFromProjects(opts, mergedProjects)
|
||||
return u.FzfProjectFromProjects(opts, mergedProjects)
|
||||
}
|
||||
|
||||
func projectsFromAliases(aliases []*cache.ProjectAlias) []*projects.Project {
|
||||
func (u *Utils) projectsFromAliases(aliases []*cache.ProjectAlias) []*projects.Project {
|
||||
projects := make([]*projects.Project, 0, len(aliases))
|
||||
|
||||
for _, a := range aliases {
|
||||
project := projectCache.GetProjectByAlias(a)
|
||||
project := u.Cache().GetProjectByAlias(a)
|
||||
if project != nil && !slices.Contains(projects, project) {
|
||||
projects = append(projects, project)
|
||||
}
|
||||
@ -121,30 +121,30 @@ func projectsFromAliases(aliases []*cache.ProjectAlias) []*projects.Project {
|
||||
|
||||
// If opts.MustHaveAlias, will only allow selection of projects
|
||||
// that have at least one alias defined
|
||||
func fzfProject(opts *fzfProjectOpts) (*projects.Project, error) {
|
||||
func (u *Utils) FzfProject(opts *FzfProjectOpts) (*projects.Project, error) {
|
||||
var searchableProjects []*projects.Project
|
||||
if opts.MustHaveAlias {
|
||||
searchableProjects = projectCache.GetProjectsWithAliases()
|
||||
searchableProjects = u.Cache().GetProjectsWithAliases()
|
||||
} else {
|
||||
searchableProjects = projectCache.Projects
|
||||
searchableProjects = u.Cache().Projects
|
||||
}
|
||||
// Filter out unwanted remotes if provided
|
||||
searchableProjects = filterProjectsWithRemotes(searchableProjects, opts.Remotes...)
|
||||
return fzfProjectFromProjects(opts, searchableProjects)
|
||||
searchableProjects = u.FilterProjectsWithRemotes(searchableProjects, opts.Remotes...)
|
||||
return u.FzfProjectFromProjects(opts, searchableProjects)
|
||||
}
|
||||
|
||||
// Takes a list of projects and performs a fuzzyfind
|
||||
func fzfProjectFromProjects(opts *fzfProjectOpts, projects []*projects.Project) (
|
||||
func (u *Utils) FzfProjectFromProjects(opts *FzfProjectOpts, projects []*projects.Project) (
|
||||
*projects.Project, error,
|
||||
) {
|
||||
i, err := fzf.Find(projects,
|
||||
func(i int) string {
|
||||
// Display the project along with its aliases
|
||||
return projectCache.GetProjectStringWithAliases(projects[i])
|
||||
return u.Cache().GetProjectStringWithAliases(projects[i])
|
||||
},
|
||||
fzf.WithPreviewWindow(
|
||||
func(i, width, height int) string {
|
||||
return projectCache.ProjectString(projects[i])
|
||||
return u.Cache().ProjectString(projects[i])
|
||||
},
|
||||
),
|
||||
fzf.WithContext(opts.Ctx),
|
||||
@ -156,12 +156,12 @@ func fzfProjectFromProjects(opts *fzfProjectOpts, projects []*projects.Project)
|
||||
return projects[i], nil
|
||||
}
|
||||
|
||||
func fzfPreviewWindow(i, w, h int) string {
|
||||
p := projectCache.Projects[i]
|
||||
return projectCache.ProjectString(p)
|
||||
func (u *Utils) FzfPreviewWindow(i, _, _ int) string {
|
||||
p := u.Cache().Projects[i]
|
||||
return u.Cache().ProjectString(p)
|
||||
}
|
||||
|
||||
func filterProjectsWithRemotes(gitProjects []*projects.Project, remotes ...string) []*projects.Project {
|
||||
func (u *Utils) FilterProjectsWithRemotes(gitProjects []*projects.Project, remotes ...string) []*projects.Project {
|
||||
filteredProjects := make([]*projects.Project, 0, len(gitProjects))
|
||||
if len(remotes) > 0 {
|
||||
for _, p := range gitProjects {
|
||||
@ -177,7 +177,7 @@ func filterProjectsWithRemotes(gitProjects []*projects.Project, remotes ...strin
|
||||
|
||||
// Nearly useless function that simply returns either an
|
||||
// empty string, or a string from the first arg if one is provided
|
||||
func searchStringFromArgs(args []string) string {
|
||||
func (u *Utils) SearchStringFromArgs(args []string) string {
|
||||
var term string
|
||||
if len(args) > 0 {
|
||||
term = args[0]
|
163
cmd/util/util_init.go
Normal file
163
cmd/util/util_init.go
Normal file
@ -0,0 +1,163 @@
|
||||
// This file contains init methods that may be used by
|
||||
// multiple sub-commands. For instance, the cach and projects
|
||||
// sub-commands both depend on a cache and may both call the initProjectCache
|
||||
// func (u *Util) from their PersistentPreRun commands
|
||||
package util
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/pterm/pterm"
|
||||
"github.com/spf13/cobra"
|
||||
"golang.org/x/sys/unix"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/cache"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/config"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes"
|
||||
gitearemote "gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/gitea"
|
||||
githubremote "gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/github"
|
||||
gitlabremote "gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/gitlab"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/remote"
|
||||
)
|
||||
|
||||
func InitProjects(cmd *cobra.Command, args []string) {
|
||||
utils, _ := FromCtx(cmd.Context())
|
||||
utils.InitProjectCache(cmd, args)
|
||||
utils.mustHaveProjects(cmd, args)
|
||||
}
|
||||
|
||||
func (u *Utils) mustHaveProjects(cmd *cobra.Command, _ []string) {
|
||||
if len(u.Cache().Projects) == 0 {
|
||||
u.Logger().Fatal("No projects to " + cmd.Name() + ", try running cache load")
|
||||
}
|
||||
}
|
||||
|
||||
func (u *Utils) InitProjectCache(cmd *cobra.Command, _ []string) {
|
||||
var err error
|
||||
u.Logger().Debug("Running pre-run for cacheCmd")
|
||||
u.Config().Cache.File = u.Config().ProjectPath + "/.cache.yaml"
|
||||
|
||||
gitRemotes := remotes.NewRemotes()
|
||||
gitRemotes.AddRemotes(*u.GetRemotes(cmd)...)
|
||||
|
||||
cacheOpts := &cache.CacheOpts{
|
||||
ProjectsPath: u.Config().ProjectPath,
|
||||
Path: u.Config().Cache.File,
|
||||
TTL: u.Config().Cache.Ttl,
|
||||
Logger: u.Logger(),
|
||||
Remotes: gitRemotes,
|
||||
Config: u.Config(),
|
||||
}
|
||||
|
||||
projectCache, err := cache.NewProjectCache(cacheOpts)
|
||||
if err != nil {
|
||||
u.Logger().Error("Failed to prepare project cache", u.Logger().Args("error", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
u.SetCache(projectCache)
|
||||
|
||||
if err := u.Cache().Read(); err != nil {
|
||||
u.Logger().Error("Cache load failed", u.Logger().Args("error", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
u.Logger().Debug("Remotes Loaded", u.Logger().Args("remotes", cacheOpts.Remotes))
|
||||
}
|
||||
|
||||
// Generically loads remotes from info.RemoteInfo in config.Remotes
|
||||
func (u *Utils) GetRemotes(cmd *cobra.Command) *remotes.Remotes {
|
||||
gitRemotes := new(remotes.Remotes)
|
||||
*gitRemotes = make([]remote.Remote, 0)
|
||||
for _, r := range u.Config().Remotes {
|
||||
// Create a copy, set context
|
||||
gitRemoteInfo := r
|
||||
gitRemoteInfo.SetContext(cmd.Context())
|
||||
var gitRemote remote.Remote
|
||||
var err error
|
||||
switch r.Type {
|
||||
case "gitlab":
|
||||
gitRemote, err = gitlabremote.NewGitlabRemote(&gitRemoteInfo)
|
||||
case "gitea":
|
||||
gitRemote, err = gitearemote.NewGiteaRemote(&gitRemoteInfo)
|
||||
case "github":
|
||||
gitRemote, err = githubremote.NewGithubRemote(&gitRemoteInfo)
|
||||
}
|
||||
if err != nil {
|
||||
u.Logger().Error("Failed to prepare remote", u.Logger().Args(
|
||||
"error", err,
|
||||
"type", r.Type))
|
||||
} else {
|
||||
*gitRemotes = append(*gitRemotes, gitRemote)
|
||||
}
|
||||
}
|
||||
return gitRemotes
|
||||
}
|
||||
|
||||
func PostProjectCmd(cmd *cobra.Command, args []string) {
|
||||
utils, _ := FromCtx(cmd.Context())
|
||||
utils.PostProjectCache(cmd, args)
|
||||
}
|
||||
|
||||
func (u *Utils) PostProjectCache(_ *cobra.Command, _ []string) {
|
||||
u.Cache().Write()
|
||||
}
|
||||
|
||||
func (u *Utils) InitProjectPath(_ *cobra.Command, _ []string) {
|
||||
u.Logger().Debug("Running persistent pre-run for rootCmd")
|
||||
var err error
|
||||
if u.Config().ProjectPath == "" {
|
||||
u.Config().ProjectPath = config.DefaultConfig.ProjectPath
|
||||
return
|
||||
}
|
||||
if u.Config().ProjectPath, err = ResolvePath(u.Config().ProjectPath); err != nil {
|
||||
u.Logger().Error("Failed to determine project path", u.Logger().Args("error", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
_, err = os.Stat(u.Config().ProjectPath)
|
||||
if err != nil {
|
||||
u.Logger().Error("Failed to stat project path, trying to create", u.Logger().Args("error", err))
|
||||
if err = os.MkdirAll(u.Config().ProjectPath, 0o750); err != nil {
|
||||
u.Logger().Error("Failed to create project path", u.Logger().Args("error", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
u.Logger().Info("Project path created", u.Logger().Args("path", u.Config().ProjectPath))
|
||||
} else {
|
||||
if err = unix.Access(u.Config().ProjectPath, unix.W_OK); err != nil {
|
||||
u.Logger().Error("Unable to write to project path", u.Logger().Args(
|
||||
"path", u.Config().ProjectPath,
|
||||
"error", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func ResolvePath(path string) (string, error) {
|
||||
if strings.HasPrefix(path, "~/") {
|
||||
usr, _ := user.Current()
|
||||
path = filepath.Join(usr.HomeDir, path[2:])
|
||||
}
|
||||
return filepath.Abs(path)
|
||||
}
|
||||
|
||||
func GetConfigName(configPath string) string {
|
||||
// Check existing config
|
||||
for _, ext := range []string{"yml", "yaml"} {
|
||||
configFile := fmt.Sprintf("%s/%s.%s", configPath, ConfigName, ext)
|
||||
legacyConfigFile := fmt.Sprintf("%s/%s.%s", configPath, LegacyConfigName, ext)
|
||||
|
||||
if _, err := os.Stat(configFile); err == nil {
|
||||
return ConfigName
|
||||
} else if _, err := os.Stat(legacyConfigFile); err == nil {
|
||||
pterm.DefaultLogger.WithWriter(os.Stderr).
|
||||
Warn(fmt.Sprintf("using legacy config path, suggest using %s/%s.yaml", configPath, ConfigName))
|
||||
return LegacyConfigName
|
||||
}
|
||||
}
|
||||
|
||||
// Nothing found, do what we want
|
||||
return ConfigName
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
func validProjectsFunc(cmd *cobra.Command, args []string, toComplete string) (
|
||||
[]string, cobra.ShellCompDirective) {
|
||||
initProjectCache(cmd, args)
|
||||
return projectCache.ProjectStrings(toComplete), cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
|
||||
func validAliasesFunc(cmd *cobra.Command, args []string, toComplete string) (
|
||||
[]string, cobra.ShellCompDirective) {
|
||||
initProjectCache(cmd, args)
|
||||
return projectCache.AliasStrings(toComplete), cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
|
||||
func validProjectsOrAliasesFunc(cmd *cobra.Command, args []string, toComplete string) (
|
||||
[]string, cobra.ShellCompDirective) {
|
||||
projectStrings, _ := validAliasesFunc(cmd, args, toComplete)
|
||||
aliasStrings, _ := validProjectsFunc(cmd, args, toComplete)
|
||||
return append(projectStrings, aliasStrings...), cobra.ShellCompDirectiveDefault
|
||||
}
|
||||
|
||||
func validRemotesFunc(cmd *cobra.Command, args []string, toComplete string) (
|
||||
[]string, cobra.ShellCompDirective) {
|
||||
remotes := make([]string, 0, len(conf.Remotes))
|
||||
for _, remote := range conf.Remotes {
|
||||
if strings.HasPrefix(remote.Host, toComplete) {
|
||||
remotes = append(remotes, remote.Host)
|
||||
}
|
||||
}
|
||||
return remotes, cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
|
||||
func validLogLevelsFunc(cmd *cobra.Command, args []string, toComplete string) (
|
||||
[]string, cobra.ShellCompDirective) {
|
||||
levels := []string{"info", "warn", "error", "debug"}
|
||||
matchingLevels := make([]string, 0, len(levels))
|
||||
for _, level := range levels {
|
||||
if strings.HasPrefix(level, toComplete) {
|
||||
matchingLevels = append(matchingLevels, level)
|
||||
}
|
||||
}
|
||||
return matchingLevels, cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
||||
|
||||
func validProjectIdFunc(cmd *cobra.Command, args []string, toComplete string) (
|
||||
[]string, cobra.ShellCompDirective) {
|
||||
initProjectCache(cmd, args)
|
||||
matchingIds := make([]string, 0, len(projectCache.Projects))
|
||||
for _, p := range projectCache.Projects {
|
||||
idString := strconv.FormatInt(int64(p.ID), 10)
|
||||
if strings.HasPrefix(idString, toComplete) {
|
||||
matchingIds = append(matchingIds, idString)
|
||||
}
|
||||
}
|
||||
return slices.Clip(matchingIds), cobra.ShellCompDirectiveNoFileComp
|
||||
}
|
122
cmd/util_init.go
122
cmd/util_init.go
@ -1,122 +0,0 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/cache"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/config"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes"
|
||||
gitearemote "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/gitea"
|
||||
githubremote "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/github"
|
||||
gitlabremote "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/gitlab"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/remote"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
// This file contains init methods that may be used by
|
||||
// multiple sub-commands. For instance, the cach and projects
|
||||
// sub-commands both depend on a cache and may both call the initProjectCache
|
||||
// func from their PersistentPreRun commands
|
||||
|
||||
func initProjectCache(cmd *cobra.Command, args []string) {
|
||||
var err error
|
||||
plog.Debug("Running pre-run for cacheCmd")
|
||||
conf.Cache.File = conf.ProjectPath + "/.cache.yaml"
|
||||
|
||||
gitRemotes := remotes.NewRemotes()
|
||||
gitRemotes.AddRemotes(*getRemotes(cmd)...)
|
||||
|
||||
cacheOpts := &cache.CacheOpts{
|
||||
ProjectsPath: conf.ProjectPath,
|
||||
Path: conf.Cache.File,
|
||||
TTL: conf.Cache.Ttl,
|
||||
Logger: plog,
|
||||
Remotes: gitRemotes,
|
||||
Config: &conf,
|
||||
}
|
||||
if projectCache, err = cache.NewProjectCache(cacheOpts); err != nil {
|
||||
plog.Error("Failed to prepare project cache", plog.Args("error", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if err := projectCache.Read(); err != nil {
|
||||
plog.Error("Cache load failed", plog.Args("error", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
plog.Debug("Remotes Loaded", plog.Args("remotes", cacheOpts.Remotes))
|
||||
}
|
||||
|
||||
// Generically loads remotes from info.RemoteInfo in config.Remotes
|
||||
func getRemotes(cmd *cobra.Command) *remotes.Remotes {
|
||||
gitRemotes := new(remotes.Remotes)
|
||||
*gitRemotes = make([]remote.Remote, 0)
|
||||
for _, r := range conf.Remotes {
|
||||
// Create a copy, set context
|
||||
gitRemoteInfo := r
|
||||
gitRemoteInfo.SetContext(cmd.Context())
|
||||
var gitRemote remote.Remote
|
||||
var err error
|
||||
switch r.Type {
|
||||
case "gitlab":
|
||||
gitRemote, err = gitlabremote.NewGitlabRemote(&gitRemoteInfo)
|
||||
case "gitea":
|
||||
gitRemote, err = gitearemote.NewGiteaRemote(&gitRemoteInfo)
|
||||
case "github":
|
||||
gitRemote, err = githubremote.NewGithubRemote(&gitRemoteInfo)
|
||||
}
|
||||
if err != nil {
|
||||
plog.Error("Failed to prepare remote", plog.Args(
|
||||
"error", err,
|
||||
"type", r.Type))
|
||||
} else {
|
||||
*gitRemotes = append(*gitRemotes, gitRemote)
|
||||
}
|
||||
}
|
||||
return gitRemotes
|
||||
}
|
||||
|
||||
func postProjectCache(cmd *cobra.Command, args []string) {
|
||||
projectCache.Write()
|
||||
}
|
||||
|
||||
func initProjectPath(cmd *cobra.Command, args []string) {
|
||||
plog.Debug("Running persistent pre-run for rootCmd")
|
||||
var err error
|
||||
if conf.ProjectPath == "" {
|
||||
conf.ProjectPath = config.DefaultConfig.ProjectPath
|
||||
return
|
||||
}
|
||||
if conf.ProjectPath, err = resolvePath(conf.ProjectPath); err != nil {
|
||||
plog.Error("Failed to determine project path", plog.Args("error", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
_, err = os.Stat(conf.ProjectPath)
|
||||
if err != nil {
|
||||
plog.Error("Failed to stat project path, trying to create", plog.Args("error", err))
|
||||
if err := os.MkdirAll(conf.ProjectPath, 0750); err != nil {
|
||||
plog.Error("Failed to create project path", plog.Args("error", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
plog.Info("Project path created", plog.Args("path", conf.ProjectPath))
|
||||
} else {
|
||||
if err = unix.Access(conf.ProjectPath, unix.W_OK); err != nil {
|
||||
plog.Error("Unable to write to project path", plog.Args(
|
||||
"path", conf.ProjectPath,
|
||||
"error", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func resolvePath(path string) (string, error) {
|
||||
if strings.HasPrefix(path, "~/") {
|
||||
usr, _ := user.Current()
|
||||
path = filepath.Join(usr.HomeDir, path[2:])
|
||||
}
|
||||
return filepath.Abs(path)
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
# Completion
|
||||
source <(gitlab-project-manager completion zsh)
|
||||
source <(git-project-manager completion zsh)
|
||||
|
||||
alias gpm="gitlab-project-manager"
|
||||
alias gpm="git-project-manager"
|
||||
|
||||
# Go to a project, specify a fzf filter or filter
|
||||
# through them all
|
||||
pgo () {
|
||||
project=` gitlab-project-manager project cd $1 `
|
||||
project=` git-project-manager project cd $1 `
|
||||
if [ $? -eq 0 ]; then
|
||||
cd $project
|
||||
fi
|
||||
@ -14,20 +14,20 @@ pgo () {
|
||||
|
||||
# Add a new project to your local projects path
|
||||
padd () {
|
||||
gitlab-project-manager project add
|
||||
git-project-manager project add
|
||||
}
|
||||
|
||||
plist () {
|
||||
gitlab-project-manager alias list
|
||||
git-project-manager alias list
|
||||
}
|
||||
|
||||
pshow () {
|
||||
gitlab-project-manager project show --current
|
||||
git-project-manager project show --current
|
||||
}
|
||||
|
||||
popen () {
|
||||
gitlab-project-manager project open $1
|
||||
git-project-manager project open $1
|
||||
reset 2>&1 > /dev/null
|
||||
}
|
||||
|
||||
alias prun="gitlab-project-manager project run"
|
||||
alias prun="git-project-manager project run"
|
||||
|
30
docs/git-project-manager.md
Normal file
30
docs/git-project-manager.md
Normal file
@ -0,0 +1,30 @@
|
||||
## git-project-manager
|
||||
|
||||
Find and use Git projects locally
|
||||
|
||||
### Synopsis
|
||||
|
||||
Finds Git projects using fuzzy-find, remembering
|
||||
your chosen term for the project as an alias, and offers helpful
|
||||
shortcuts for moving around in projects and opening your code
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
--config string config file (default is ~/.config/git-project-manager.yaml)
|
||||
-h, --help help for git-project-manager
|
||||
--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.
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [git-project-manager alias](git-project-manager_alias.md) - Manage project aliases
|
||||
* [git-project-manager cache](git-project-manager_cache.md) - Manage Git project cache
|
||||
* [git-project-manager completion](git-project-manager_completion.md) - Generate the autocompletion script for the specified shell
|
||||
* [git-project-manager config](git-project-manager_config.md) - Git Project Manager Configuration
|
||||
* [git-project-manager docs](git-project-manager_docs.md) - Generate documentation for git-project-manager
|
||||
* [git-project-manager project](git-project-manager_project.md) - Use a Git project
|
||||
|
||||
###### Auto generated by spf13/cobra on 31-Dec-2024
|
32
docs/git-project-manager_alias.md
Normal file
32
docs/git-project-manager_alias.md
Normal file
@ -0,0 +1,32 @@
|
||||
## git-project-manager alias
|
||||
|
||||
Manage project aliases
|
||||
|
||||
### Synopsis
|
||||
|
||||
Manages project aliases, with options for
|
||||
listing, adding, and deleting.
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for alias
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--config string config file (default is ~/.config/git-project-manager.yaml)
|
||||
--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.
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [git-project-manager](git-project-manager.md) - Find and use Git projects locally
|
||||
* [git-project-manager alias add](git-project-manager_alias_add.md) - Add a project alias
|
||||
* [git-project-manager alias delete](git-project-manager_alias_delete.md) - Delete a project alias
|
||||
* [git-project-manager alias list](git-project-manager_alias_list.md) - List Aliases
|
||||
|
||||
###### Auto generated by spf13/cobra on 31-Dec-2024
|
34
docs/git-project-manager_alias_add.md
Normal file
34
docs/git-project-manager_alias_add.md
Normal file
@ -0,0 +1,34 @@
|
||||
## git-project-manager alias add
|
||||
|
||||
Add a project alias
|
||||
|
||||
### Synopsis
|
||||
|
||||
Adds a project alias to a project
|
||||
project ID can be provided, or will otherwise use fuzzy find
|
||||
|
||||
```
|
||||
git-project-manager alias add [flags]
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for add
|
||||
--projectID int Specify a project by ID
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--config string config file (default is ~/.config/git-project-manager.yaml)
|
||||
--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.
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [git-project-manager alias](git-project-manager_alias.md) - Manage project aliases
|
||||
|
||||
###### Auto generated by spf13/cobra on 31-Dec-2024
|
34
docs/git-project-manager_alias_delete.md
Normal file
34
docs/git-project-manager_alias_delete.md
Normal file
@ -0,0 +1,34 @@
|
||||
## git-project-manager alias delete
|
||||
|
||||
Delete a project alias
|
||||
|
||||
### Synopsis
|
||||
|
||||
Deletes aliases from projects
|
||||
project ID can be provided, or will otherwise use fuzzy find
|
||||
|
||||
```
|
||||
git-project-manager alias delete [fuzzy project or alias] [flags]
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for delete
|
||||
--projectID int Specify a project by ID
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--config string config file (default is ~/.config/git-project-manager.yaml)
|
||||
--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.
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [git-project-manager alias](git-project-manager_alias.md) - Manage project aliases
|
||||
|
||||
###### Auto generated by spf13/cobra on 31-Dec-2024
|
32
docs/git-project-manager_alias_list.md
Normal file
32
docs/git-project-manager_alias_list.md
Normal file
@ -0,0 +1,32 @@
|
||||
## git-project-manager alias list
|
||||
|
||||
List Aliases
|
||||
|
||||
### Synopsis
|
||||
|
||||
Lists all aliases by project
|
||||
|
||||
```
|
||||
git-project-manager alias list [flags]
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for list
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--config string config file (default is ~/.config/git-project-manager.yaml)
|
||||
--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.
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [git-project-manager alias](git-project-manager_alias.md) - Manage project aliases
|
||||
|
||||
###### Auto generated by spf13/cobra on 31-Dec-2024
|
35
docs/git-project-manager_cache.md
Normal file
35
docs/git-project-manager_cache.md
Normal file
@ -0,0 +1,35 @@
|
||||
## git-project-manager cache
|
||||
|
||||
Manage Git project cache
|
||||
|
||||
### Synopsis
|
||||
|
||||
Contains sub-commands for managing project cache.
|
||||
The project cache keeps this speedy, without smashing against the Git
|
||||
API every time a new project is added / searched for
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for cache
|
||||
--ttl duration Duration before cache is re-built in go time.Duration format (default 48h0m0s)
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--config string config file (default is ~/.config/git-project-manager.yaml)
|
||||
--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.
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [git-project-manager](git-project-manager.md) - Find and use Git projects locally
|
||||
* [git-project-manager cache clear](git-project-manager_cache_clear.md) - Clear Git Project Cache
|
||||
* [git-project-manager cache dump](git-project-manager_cache_dump.md) - Dump Git project cache
|
||||
* [git-project-manager cache load](git-project-manager_cache_load.md) - Load Git Project Cache
|
||||
* [git-project-manager cache unlock](git-project-manager_cache_unlock.md) - unlock Git project cache
|
||||
|
||||
###### Auto generated by spf13/cobra on 31-Dec-2024
|
36
docs/git-project-manager_cache_clear.md
Normal file
36
docs/git-project-manager_cache_clear.md
Normal file
@ -0,0 +1,36 @@
|
||||
## git-project-manager cache clear
|
||||
|
||||
Clear Git Project Cache
|
||||
|
||||
### Synopsis
|
||||
|
||||
Used to reset a project cache, forcing it to be rebuilt.
|
||||
|
||||
If --clearAliases is provided, will also reset aliases. Use with caution.
|
||||
|
||||
```
|
||||
git-project-manager cache clear [flags]
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
--clearAliases Will also clear aliases from the cache, use with caution
|
||||
-h, --help help for clear
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--config string config file (default is ~/.config/git-project-manager.yaml)
|
||||
--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.
|
||||
--ttl duration Duration before cache is re-built in go time.Duration format (default 48h0m0s)
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [git-project-manager cache](git-project-manager_cache.md) - Manage Git project cache
|
||||
|
||||
###### Auto generated by spf13/cobra on 31-Dec-2024
|
34
docs/git-project-manager_cache_dump.md
Normal file
34
docs/git-project-manager_cache_dump.md
Normal file
@ -0,0 +1,34 @@
|
||||
## git-project-manager cache dump
|
||||
|
||||
Dump Git project cache
|
||||
|
||||
### Synopsis
|
||||
|
||||
Dumps cache to display
|
||||
|
||||
```
|
||||
git-project-manager cache dump [flags]
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-f, --full Dumps entire cache
|
||||
-h, --help help for dump
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--config string config file (default is ~/.config/git-project-manager.yaml)
|
||||
--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.
|
||||
--ttl duration Duration before cache is re-built in go time.Duration format (default 48h0m0s)
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [git-project-manager cache](git-project-manager_cache.md) - Manage Git project cache
|
||||
|
||||
###### Auto generated by spf13/cobra on 31-Dec-2024
|
36
docs/git-project-manager_cache_load.md
Normal file
36
docs/git-project-manager_cache_load.md
Normal file
@ -0,0 +1,36 @@
|
||||
## git-project-manager cache load
|
||||
|
||||
Load Git Project Cache
|
||||
|
||||
### Synopsis
|
||||
|
||||
Used to initialize or update a new Git cache. With thousands
|
||||
of projects, it would be too much work to hit the API every time a user
|
||||
wants to find a new project.
|
||||
|
||||
```
|
||||
git-project-manager cache load [flags]
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for load
|
||||
--ownerOnly Only load projects that you are owner of (default true)
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--config string config file (default is ~/.config/git-project-manager.yaml)
|
||||
--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.
|
||||
--ttl duration Duration before cache is re-built in go time.Duration format (default 48h0m0s)
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [git-project-manager cache](git-project-manager_cache.md) - Manage Git project cache
|
||||
|
||||
###### Auto generated by spf13/cobra on 31-Dec-2024
|
34
docs/git-project-manager_cache_unlock.md
Normal file
34
docs/git-project-manager_cache_unlock.md
Normal file
@ -0,0 +1,34 @@
|
||||
## git-project-manager cache unlock
|
||||
|
||||
unlock Git project cache
|
||||
|
||||
### Synopsis
|
||||
|
||||
unlocks cache to display
|
||||
|
||||
```
|
||||
git-project-manager cache unlock [flags]
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-f, --force force unlocks cache (don't ask)
|
||||
-h, --help help for unlock
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--config string config file (default is ~/.config/git-project-manager.yaml)
|
||||
--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.
|
||||
--ttl duration Duration before cache is re-built in go time.Duration format (default 48h0m0s)
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [git-project-manager cache](git-project-manager_cache.md) - Manage Git project cache
|
||||
|
||||
###### Auto generated by spf13/cobra on 31-Dec-2024
|
34
docs/git-project-manager_completion.md
Normal file
34
docs/git-project-manager_completion.md
Normal file
@ -0,0 +1,34 @@
|
||||
## git-project-manager completion
|
||||
|
||||
Generate the autocompletion script for the specified shell
|
||||
|
||||
### Synopsis
|
||||
|
||||
Generate the autocompletion script for git-project-manager for the specified shell.
|
||||
See each sub-command's help for details on how to use the generated script.
|
||||
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for completion
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--config string config file (default is ~/.config/git-project-manager.yaml)
|
||||
--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.
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [git-project-manager](git-project-manager.md) - Find and use Git projects locally
|
||||
* [git-project-manager completion bash](git-project-manager_completion_bash.md) - Generate the autocompletion script for bash
|
||||
* [git-project-manager completion fish](git-project-manager_completion_fish.md) - Generate the autocompletion script for fish
|
||||
* [git-project-manager completion powershell](git-project-manager_completion_powershell.md) - Generate the autocompletion script for powershell
|
||||
* [git-project-manager completion zsh](git-project-manager_completion_zsh.md) - Generate the autocompletion script for zsh
|
||||
|
||||
###### Auto generated by spf13/cobra on 31-Dec-2024
|
53
docs/git-project-manager_completion_bash.md
Normal file
53
docs/git-project-manager_completion_bash.md
Normal file
@ -0,0 +1,53 @@
|
||||
## git-project-manager completion bash
|
||||
|
||||
Generate the autocompletion script for bash
|
||||
|
||||
### Synopsis
|
||||
|
||||
Generate the autocompletion script for the bash shell.
|
||||
|
||||
This script depends on the 'bash-completion' package.
|
||||
If it is not installed already, you can install it via your OS's package manager.
|
||||
|
||||
To load completions in your current shell session:
|
||||
|
||||
source <(git-project-manager completion bash)
|
||||
|
||||
To load completions for every new session, execute once:
|
||||
|
||||
#### Linux:
|
||||
|
||||
git-project-manager completion bash > /etc/bash_completion.d/git-project-manager
|
||||
|
||||
#### macOS:
|
||||
|
||||
git-project-manager completion bash > $(brew --prefix)/etc/bash_completion.d/git-project-manager
|
||||
|
||||
You will need to start a new shell for this setup to take effect.
|
||||
|
||||
|
||||
```
|
||||
git-project-manager completion bash
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for bash
|
||||
--no-descriptions disable completion descriptions
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--config string config file (default is ~/.config/git-project-manager.yaml)
|
||||
--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.
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [git-project-manager completion](git-project-manager_completion.md) - Generate the autocompletion script for the specified shell
|
||||
|
||||
###### Auto generated by spf13/cobra on 31-Dec-2024
|
44
docs/git-project-manager_completion_fish.md
Normal file
44
docs/git-project-manager_completion_fish.md
Normal file
@ -0,0 +1,44 @@
|
||||
## git-project-manager completion fish
|
||||
|
||||
Generate the autocompletion script for fish
|
||||
|
||||
### Synopsis
|
||||
|
||||
Generate the autocompletion script for the fish shell.
|
||||
|
||||
To load completions in your current shell session:
|
||||
|
||||
git-project-manager completion fish | source
|
||||
|
||||
To load completions for every new session, execute once:
|
||||
|
||||
git-project-manager completion fish > ~/.config/fish/completions/git-project-manager.fish
|
||||
|
||||
You will need to start a new shell for this setup to take effect.
|
||||
|
||||
|
||||
```
|
||||
git-project-manager completion fish [flags]
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for fish
|
||||
--no-descriptions disable completion descriptions
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--config string config file (default is ~/.config/git-project-manager.yaml)
|
||||
--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.
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [git-project-manager completion](git-project-manager_completion.md) - Generate the autocompletion script for the specified shell
|
||||
|
||||
###### Auto generated by spf13/cobra on 31-Dec-2024
|
41
docs/git-project-manager_completion_powershell.md
Normal file
41
docs/git-project-manager_completion_powershell.md
Normal file
@ -0,0 +1,41 @@
|
||||
## git-project-manager completion powershell
|
||||
|
||||
Generate the autocompletion script for powershell
|
||||
|
||||
### Synopsis
|
||||
|
||||
Generate the autocompletion script for powershell.
|
||||
|
||||
To load completions in your current shell session:
|
||||
|
||||
git-project-manager completion powershell | Out-String | Invoke-Expression
|
||||
|
||||
To load completions for every new session, add the output of the above command
|
||||
to your powershell profile.
|
||||
|
||||
|
||||
```
|
||||
git-project-manager completion powershell [flags]
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for powershell
|
||||
--no-descriptions disable completion descriptions
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--config string config file (default is ~/.config/git-project-manager.yaml)
|
||||
--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.
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [git-project-manager completion](git-project-manager_completion.md) - Generate the autocompletion script for the specified shell
|
||||
|
||||
###### Auto generated by spf13/cobra on 31-Dec-2024
|
55
docs/git-project-manager_completion_zsh.md
Normal file
55
docs/git-project-manager_completion_zsh.md
Normal file
@ -0,0 +1,55 @@
|
||||
## git-project-manager completion zsh
|
||||
|
||||
Generate the autocompletion script for zsh
|
||||
|
||||
### Synopsis
|
||||
|
||||
Generate the autocompletion script for the zsh shell.
|
||||
|
||||
If shell completion is not already enabled in your environment you will need
|
||||
to enable it. You can execute the following once:
|
||||
|
||||
echo "autoload -U compinit; compinit" >> ~/.zshrc
|
||||
|
||||
To load completions in your current shell session:
|
||||
|
||||
source <(git-project-manager completion zsh)
|
||||
|
||||
To load completions for every new session, execute once:
|
||||
|
||||
#### Linux:
|
||||
|
||||
git-project-manager completion zsh > "${fpath[1]}/_git-project-manager"
|
||||
|
||||
#### macOS:
|
||||
|
||||
git-project-manager completion zsh > $(brew --prefix)/share/zsh/site-functions/_git-project-manager
|
||||
|
||||
You will need to start a new shell for this setup to take effect.
|
||||
|
||||
|
||||
```
|
||||
git-project-manager completion zsh [flags]
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for zsh
|
||||
--no-descriptions disable completion descriptions
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--config string config file (default is ~/.config/git-project-manager.yaml)
|
||||
--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.
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [git-project-manager completion](git-project-manager_completion.md) - Generate the autocompletion script for the specified shell
|
||||
|
||||
###### Auto generated by spf13/cobra on 31-Dec-2024
|
31
docs/git-project-manager_config.md
Normal file
31
docs/git-project-manager_config.md
Normal file
@ -0,0 +1,31 @@
|
||||
## git-project-manager config
|
||||
|
||||
Git Project Manager Configuration
|
||||
|
||||
### Synopsis
|
||||
|
||||
Commands for managing configuration, particulary
|
||||
useful for seeding a new config file
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for config
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--config string config file (default is ~/.config/git-project-manager.yaml)
|
||||
--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.
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [git-project-manager](git-project-manager.md) - Find and use Git projects locally
|
||||
* [git-project-manager config generate](git-project-manager_config_generate.md) - Generate a default configuration
|
||||
* [git-project-manager config show](git-project-manager_config_show.md) - Show Git Project Manager Configuration
|
||||
|
||||
###### Auto generated by spf13/cobra on 31-Dec-2024
|
35
docs/git-project-manager_config_generate.md
Normal file
35
docs/git-project-manager_config_generate.md
Normal file
@ -0,0 +1,35 @@
|
||||
## git-project-manager config generate
|
||||
|
||||
Generate a default configuration
|
||||
|
||||
### Synopsis
|
||||
|
||||
Produces yaml to stdout that can be used
|
||||
to seed the configuration file
|
||||
|
||||
```
|
||||
git-project-manager config generate [flags]
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for generate
|
||||
--prompt Prompt for settings
|
||||
--write Write config to file
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--config string config file (default is ~/.config/git-project-manager.yaml)
|
||||
--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.
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [git-project-manager config](git-project-manager_config.md) - Git Project Manager Configuration
|
||||
|
||||
###### Auto generated by spf13/cobra on 31-Dec-2024
|
29
docs/git-project-manager_config_show.md
Normal file
29
docs/git-project-manager_config_show.md
Normal file
@ -0,0 +1,29 @@
|
||||
## git-project-manager config show
|
||||
|
||||
Show Git Project Manager Configuration
|
||||
|
||||
```
|
||||
git-project-manager config show [flags]
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for show
|
||||
-s, --sensitive Set to show sensitive fields
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--config string config file (default is ~/.config/git-project-manager.yaml)
|
||||
--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.
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [git-project-manager config](git-project-manager_config.md) - Git Project Manager Configuration
|
||||
|
||||
###### Auto generated by spf13/cobra on 31-Dec-2024
|
29
docs/git-project-manager_docs.md
Normal file
29
docs/git-project-manager_docs.md
Normal file
@ -0,0 +1,29 @@
|
||||
## git-project-manager docs
|
||||
|
||||
Generate documentation for git-project-manager
|
||||
|
||||
```
|
||||
git-project-manager docs [flags]
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-d, --docsPath string specify output directory for documentation (default "./docs")
|
||||
-h, --help help for docs
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--config string config file (default is ~/.config/git-project-manager.yaml)
|
||||
--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.
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [git-project-manager](git-project-manager.md) - Find and use Git projects locally
|
||||
|
||||
###### Auto generated by spf13/cobra on 31-Dec-2024
|
38
docs/git-project-manager_project.md
Normal file
38
docs/git-project-manager_project.md
Normal file
@ -0,0 +1,38 @@
|
||||
## git-project-manager project
|
||||
|
||||
Use a Git project
|
||||
|
||||
### Synopsis
|
||||
|
||||
Switches to a Git project by name or alias
|
||||
If not found, will enter fzf mode. If not cloned, will clone
|
||||
the project locally.
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for project
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--config string config file (default is ~/.config/git-project-manager.yaml)
|
||||
--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.
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [git-project-manager](git-project-manager.md) - Find and use Git projects locally
|
||||
* [git-project-manager project add](git-project-manager_project_add.md) - Add a new Git project
|
||||
* [git-project-manager project go](git-project-manager_project_go.md) - Go to a Git project
|
||||
* [git-project-manager project list](git-project-manager_project_list.md) - List Git Projects
|
||||
* [git-project-manager project open](git-project-manager_project_open.md) - Open project in your IDE
|
||||
* [git-project-manager project run](git-project-manager_project_run.md) - Run the project (e.g. go run .)
|
||||
* [git-project-manager project run](git-project-manager_project_run.md) - Run the project (e.g. go run .)
|
||||
* [git-project-manager project show](git-project-manager_project_show.md) - Show detail for a Git project
|
||||
* [git-project-manager project show](git-project-manager_project_show.md) - Show detail for a Git project
|
||||
|
||||
###### Auto generated by spf13/cobra on 31-Dec-2024
|
33
docs/git-project-manager_project_add.md
Normal file
33
docs/git-project-manager_project_add.md
Normal file
@ -0,0 +1,33 @@
|
||||
## git-project-manager project add
|
||||
|
||||
Add a new Git project
|
||||
|
||||
### Synopsis
|
||||
|
||||
Adds a new project to the local project path
|
||||
uses fuzzy find to locate the project
|
||||
|
||||
```
|
||||
git-project-manager project add [flags]
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for add
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--config string config file (default is ~/.config/git-project-manager.yaml)
|
||||
--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.
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [git-project-manager project](git-project-manager_project.md) - Use a Git project
|
||||
|
||||
###### Auto generated by spf13/cobra on 31-Dec-2024
|
36
docs/git-project-manager_project_go.md
Normal file
36
docs/git-project-manager_project_go.md
Normal file
@ -0,0 +1,36 @@
|
||||
## git-project-manager project go
|
||||
|
||||
Go to a Git project
|
||||
|
||||
### Synopsis
|
||||
|
||||
Go to a project, searching by alias
|
||||
If project is not already cloned, its path will be built and it
|
||||
will be cloned from source control.
|
||||
|
||||
If conf.projects.alwaysPull, a git pull will be ran automatically
|
||||
|
||||
```
|
||||
git-project-manager project go [fuzzy alias search] [flags]
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for go
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--config string config file (default is ~/.config/git-project-manager.yaml)
|
||||
--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.
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [git-project-manager project](git-project-manager_project.md) - Use a Git project
|
||||
|
||||
###### Auto generated by spf13/cobra on 31-Dec-2024
|
34
docs/git-project-manager_project_list.md
Normal file
34
docs/git-project-manager_project_list.md
Normal file
@ -0,0 +1,34 @@
|
||||
## git-project-manager project list
|
||||
|
||||
List Git Projects
|
||||
|
||||
### Synopsis
|
||||
|
||||
List locally cloned projects. Optionally
|
||||
lists all projects in project cache
|
||||
|
||||
```
|
||||
git-project-manager project list [flags]
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
--all List all, not just cloned locally
|
||||
-h, --help help for list
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--config string config file (default is ~/.config/git-project-manager.yaml)
|
||||
--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.
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [git-project-manager project](git-project-manager_project.md) - Use a Git project
|
||||
|
||||
###### Auto generated by spf13/cobra on 31-Dec-2024
|
39
docs/git-project-manager_project_open.md
Normal file
39
docs/git-project-manager_project_open.md
Normal file
@ -0,0 +1,39 @@
|
||||
## git-project-manager project open
|
||||
|
||||
Open project in your IDE
|
||||
|
||||
### Synopsis
|
||||
|
||||
Opens the given project directory in the editor
|
||||
of your choice. Will find certain well-known entrypoints (e.g. main.go).
|
||||
|
||||
If your editor is set in your config file, it will be used, otherwise
|
||||
one will be found in your path from a list of known defaults.
|
||||
|
||||
```
|
||||
git-project-manager project open [fuzzy alias search] [flags]
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
--binary string Path to editor binary
|
||||
--displayName string Set display name of editor (meant for config file)
|
||||
-h, --help help for open
|
||||
--openFlags string Optional flags when opening project (e.g. --reuse-window)
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--config string config file (default is ~/.config/git-project-manager.yaml)
|
||||
--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.
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [git-project-manager project](git-project-manager_project.md) - Use a Git project
|
||||
|
||||
###### Auto generated by spf13/cobra on 31-Dec-2024
|
33
docs/git-project-manager_project_run.md
Normal file
33
docs/git-project-manager_project_run.md
Normal file
@ -0,0 +1,33 @@
|
||||
## git-project-manager project run
|
||||
|
||||
Run the project (e.g. go run .)
|
||||
|
||||
### Synopsis
|
||||
|
||||
Runs the current project. Tries to detect
|
||||
the language and runs accordingly (e.g. go run .)
|
||||
|
||||
```
|
||||
git-project-manager project run [flags]
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for run
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--config string config file (default is ~/.config/git-project-manager.yaml)
|
||||
--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.
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [git-project-manager project](git-project-manager_project.md) - Use a Git project
|
||||
|
||||
###### Auto generated by spf13/cobra on 31-Dec-2024
|
34
docs/git-project-manager_project_show.md
Normal file
34
docs/git-project-manager_project_show.md
Normal file
@ -0,0 +1,34 @@
|
||||
## git-project-manager project show
|
||||
|
||||
Show detail for a Git project
|
||||
|
||||
### Synopsis
|
||||
|
||||
Shows detail for a particular project
|
||||
Will always fuzzy find
|
||||
|
||||
```
|
||||
git-project-manager project show [fuzzy alias search] [flags]
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
--current Use project in CWD rather than fuzzy find
|
||||
-h, --help help for show
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--config string config file (default is ~/.config/git-project-manager.yaml)
|
||||
--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.
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [git-project-manager project](git-project-manager_project.md) - Use a Git project
|
||||
|
||||
###### Auto generated by spf13/cobra on 31-Dec-2024
|
17
go.mod
17
go.mod
@ -1,9 +1,9 @@
|
||||
module gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager
|
||||
module gitea.libretechconsulting.com/rmcguire/git-project-manager
|
||||
|
||||
go 1.23.4
|
||||
|
||||
require (
|
||||
github.com/go-git/go-git/v5 v5.12.0
|
||||
github.com/go-git/go-git/v5 v5.13.0
|
||||
github.com/ktr0731/go-fuzzyfinder v0.8.0
|
||||
github.com/lithammer/fuzzysearch v1.1.8
|
||||
github.com/pterm/pterm v0.12.80
|
||||
@ -16,6 +16,15 @@ require (
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect
|
||||
github.com/mmcloughlin/avo v0.6.0 // indirect
|
||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||
golang.org/x/mod v0.22.0 // indirect
|
||||
golang.org/x/sync v0.10.0 // indirect
|
||||
golang.org/x/tools v0.28.0 // indirect
|
||||
)
|
||||
|
||||
require (
|
||||
atomicgo.dev/cursor v0.2.0 // indirect
|
||||
atomicgo.dev/keyboard v0.2.9 // indirect
|
||||
@ -34,7 +43,7 @@ require (
|
||||
github.com/gdamore/tcell/v2 v2.7.4 // indirect
|
||||
github.com/go-fed/httpsig v1.1.0 // indirect
|
||||
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
|
||||
github.com/go-git/go-billy/v5 v5.6.0 // indirect
|
||||
github.com/go-git/go-billy/v5 v5.6.1 // indirect
|
||||
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
|
||||
github.com/google/go-github/v58 v58.0.0 // direct
|
||||
github.com/google/go-querystring v1.1.0 // indirect
|
||||
@ -53,7 +62,7 @@ require (
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/nsf/termbox-go v1.1.1 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
|
||||
github.com/pjbgf/sha1cd v0.3.0 // indirect
|
||||
github.com/pjbgf/sha1cd v0.3.1 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/rivo/uniseg v0.4.7 // indirect
|
||||
github.com/sagikazarmark/locafero v0.6.0 // indirect
|
||||
|
154
go.sum
154
go.sum
@ -6,12 +6,8 @@ atomicgo.dev/keyboard v0.2.9 h1:tOsIid3nlPLZ3lwgG8KZMp/SFmr7P0ssEN5JUsm78K8=
|
||||
atomicgo.dev/keyboard v0.2.9/go.mod h1:BC4w9g00XkxH/f1HXhW2sXmJFOCWbKn9xrOunSFtExQ=
|
||||
atomicgo.dev/schedule v0.1.0 h1:nTthAbhZS5YZmgYbb2+DH8uQIZcTlIrd4eYr3UQxEjs=
|
||||
atomicgo.dev/schedule v0.1.0/go.mod h1:xeUa3oAkiuHYh8bKiQBRojqAMq3PXXbJujjb0hw8pEU=
|
||||
code.gitea.io/sdk/gitea v0.18.0 h1:+zZrwVmujIrgobt6wVBWCqITz6bn1aBjnCUHmpZrerI=
|
||||
code.gitea.io/sdk/gitea v0.18.0/go.mod h1:IG9xZJoltDNeDSW0qiF2Vqx5orMWa7OhVWrjvrd5NpI=
|
||||
code.gitea.io/sdk/gitea v0.19.0 h1:8I6s1s4RHgzxiPHhOQdgim1RWIRcr0LVMbHBjBFXq4Y=
|
||||
code.gitea.io/sdk/gitea v0.19.0/go.mod h1:IG9xZJoltDNeDSW0qiF2Vqx5orMWa7OhVWrjvrd5NpI=
|
||||
dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
|
||||
dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
|
||||
dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s=
|
||||
dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
|
||||
github.com/MarvinJWendt/testza v0.1.0/go.mod h1:7AxNvlfeHP7Z/hDQ5JtE3OKYT3XFUeLCDE2DQninSqs=
|
||||
@ -26,10 +22,6 @@ github.com/MarvinJWendt/testza v0.5.2/go.mod h1:xu53QFE5sCdjtMCKk8YMQ2MnymimEctc
|
||||
github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=
|
||||
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
|
||||
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
|
||||
github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0kC2U78=
|
||||
github.com/ProtonMail/go-crypto v1.0.0/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0=
|
||||
github.com/ProtonMail/go-crypto v1.1.2 h1:A7JbD57ThNqh7XjmHE+PXpQ3Dqt3BrSAC0AL0Go3KS0=
|
||||
github.com/ProtonMail/go-crypto v1.1.2/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE=
|
||||
github.com/ProtonMail/go-crypto v1.1.3 h1:nRBOetoydLeUb4nHajyO2bKqMLfWQ/ZPwkXqXxPxCFk=
|
||||
github.com/ProtonMail/go-crypto v1.1.3/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE=
|
||||
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8=
|
||||
@ -37,27 +29,14 @@ github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuW
|
||||
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
|
||||
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
|
||||
github.com/atomicgo/cursor v0.0.1/go.mod h1:cBON2QmmrysudxNBFthvMtN32r3jxVRIvzkUiF/RuIk=
|
||||
github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
|
||||
github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA=
|
||||
github.com/cloudflare/circl v1.3.8 h1:j+V8jJt09PoeMFIu2uh5JUyEaIHTXVOHslFoLNAKqwI=
|
||||
github.com/cloudflare/circl v1.3.8/go.mod h1:PDRU+oXvdD7KCtgKxW95M5Z8BpSCJXQORiZFnBQS5QU=
|
||||
github.com/cloudflare/circl v1.4.0 h1:BV7h5MgrktNzytKmWjpOtdYrf0lkkbF8YMlBGPhJQrY=
|
||||
github.com/cloudflare/circl v1.4.0/go.mod h1:PDRU+oXvdD7KCtgKxW95M5Z8BpSCJXQORiZFnBQS5QU=
|
||||
github.com/cloudflare/circl v1.5.0 h1:hxIWksrX6XN5a1L2TI/h53AGPhNHoUBo+TD1ms9+pys=
|
||||
github.com/cloudflare/circl v1.5.0/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs=
|
||||
github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U=
|
||||
github.com/containerd/console v1.0.4 h1:F2g4+oChYvBTsASRTz8NP6iIAi97J3TtSAsLbIFn4ro=
|
||||
github.com/containerd/console v1.0.4/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/cyphar/filepath-securejoin v0.2.5 h1:6iR5tXJ/e6tJZzzdMc1km3Sa7RRIVBKAK32O2s7AYfo=
|
||||
github.com/cyphar/filepath-securejoin v0.2.5/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4=
|
||||
github.com/cyphar/filepath-securejoin v0.3.2 h1:QhZu5AxQ+o1XZH0Ye05YzvJ0kAdK6VQc0z9NNMek7gc=
|
||||
github.com/cyphar/filepath-securejoin v0.3.2/go.mod h1:F7i41x/9cBF7lzCrVsYs9fuzwRZm4NQsGTBdpp6mETc=
|
||||
github.com/cyphar/filepath-securejoin v0.3.3 h1:lofZkCEVFIBe0KcdQOzFs8Soy9oaHOWl4gGtPI+gCFc=
|
||||
github.com/cyphar/filepath-securejoin v0.3.3/go.mod h1:8s/MCNJREmFK0H02MF6Ihv1nakJe4L/w3WZLHNkvlYM=
|
||||
github.com/cyphar/filepath-securejoin v0.3.4 h1:VBWugsJh2ZxJmLFSM06/0qzQyiQX2Qs0ViKrUAcqdZ8=
|
||||
github.com/cyphar/filepath-securejoin v0.3.4/go.mod h1:8s/MCNJREmFK0H02MF6Ihv1nakJe4L/w3WZLHNkvlYM=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.6 h1:XJtiaUW6dEEqVuZiMTn1ldk455QWwEIsMIJlo5vtkx0=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
|
||||
github.com/cyphar/filepath-securejoin v0.3.6 h1:4d9N5ykBnSp5Xn2JkhocYDkOpURL/18CYMpo6xB9uWM=
|
||||
github.com/cyphar/filepath-securejoin v0.3.6/go.mod h1:Sdj7gXlvMcPZsbhwhQ33GguGLDGQL7h7bg04C/+u9jI=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
@ -68,14 +47,13 @@ github.com/davidmz/go-pageant v1.0.2 h1:bPblRCh5jGU+Uptpz6LgMZGD5hJoOt7otgT454Wv
|
||||
github.com/davidmz/go-pageant v1.0.2/go.mod h1:P2EDDnMqIwG5Rrp05dTRITj9z2zpGcD9efWSkTNKLIE=
|
||||
github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a h1:mATvB/9r/3gvcejNsXKSkQ6lcIaNec2nyfOdlTBR2lU=
|
||||
github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM=
|
||||
github.com/elazarl/goproxy v1.2.1 h1:njjgvO6cRG9rIqN2ebkqy6cQz2Njkx7Fsfv/zIZqgug=
|
||||
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
|
||||
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
|
||||
github.com/fatih/color v1.14.1 h1:qfhVLaG5s+nCROl1zJsZRxFeYrHLqWroPOQ8BWiNb4w=
|
||||
github.com/fatih/color v1.14.1/go.mod h1:2oHN61fhTpgcxD3TSWCgKDiH1+x4OiDVVGH8WlgGZGg=
|
||||
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
|
||||
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
|
||||
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
|
||||
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
|
||||
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
|
||||
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
|
||||
github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=
|
||||
github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
|
||||
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
|
||||
@ -86,20 +64,21 @@ github.com/gdamore/tcell/v2 v2.7.4 h1:sg6/UnTM9jGpZU+oFYAsDahfchWAFW8Xx2yFinNSAY
|
||||
github.com/gdamore/tcell/v2 v2.7.4/go.mod h1:dSXtXTSK0VsW1biw65DZLZ2NKr7j0qP/0J7ONmsraWg=
|
||||
github.com/gliderlabs/ssh v0.3.7 h1:iV3Bqi942d9huXnzEF2Mt+CY9gLu8DNM4Obd+8bODRE=
|
||||
github.com/gliderlabs/ssh v0.3.7/go.mod h1:zpHEXBstFnQYtGnB8k8kQLol82umzn/2/snG7alWVD8=
|
||||
github.com/gliderlabs/ssh v0.3.8 h1:a4YXD1V7xMF9g5nTkdfnja3Sxy1PVDCj1Zg4Wb8vY6c=
|
||||
github.com/go-fed/httpsig v1.1.0 h1:9M+hb0jkEICD8/cAiNqEB66R87tTINszBRTjwjQzWcI=
|
||||
github.com/go-fed/httpsig v1.1.0/go.mod h1:RCMrTZvN1bJYtofsG4rd5NaO5obxQ5xBkdiS7xsT7bM=
|
||||
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI=
|
||||
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic=
|
||||
github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU=
|
||||
github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow=
|
||||
github.com/go-git/go-billy/v5 v5.6.0 h1:w2hPNtoehvJIxR00Vb4xX94qHQi/ApZfX+nBE2Cjio8=
|
||||
github.com/go-git/go-billy/v5 v5.6.0/go.mod h1:sFDq7xD3fn3E0GOwUSZqHo9lrkmx8xJhA0ZrfvjBRGM=
|
||||
github.com/go-git/go-billy/v5 v5.6.1 h1:u+dcrgaguSSkbjzHwelEjc0Yj300NUevrrPphk/SoRA=
|
||||
github.com/go-git/go-billy/v5 v5.6.1/go.mod h1:0AsLr1z2+Uksi4NlElmMblP5rPcDZNRCD8ujZCRR2BE=
|
||||
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4=
|
||||
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII=
|
||||
github.com/go-git/go-git/v5 v5.12.0 h1:7Md+ndsjrzZxbddRDZjF14qK+NN56sy6wkqaVrjZtys=
|
||||
github.com/go-git/go-git/v5 v5.12.0/go.mod h1:FTM9VKtnI2m65hNI/TenDDDnUf2Q9FHnXYjuz9i5OEY=
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/go-git/go-git/v5 v5.13.0 h1:vLn5wlGIh/X78El6r3Jr+30W16Blk0CTcxTYcYPWi5E=
|
||||
github.com/go-git/go-git/v5 v5.13.0/go.mod h1:Wjo7/JyVKtQgUNdXYXIepzWfJQkUEIGvkvVkiXRR/zw=
|
||||
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 h1:f+oWsMOmNPc8JmEHVZIycC7hBoQxHH9pNKQORJNozsQ=
|
||||
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8/go.mod h1:wcDNUvekVysuuOpQKo3191zZyTpiI6se1N1ULghS0sw=
|
||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
@ -117,15 +96,10 @@ github.com/gookit/color v1.5.4 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0=
|
||||
github.com/gookit/color v1.5.4/go.mod h1:pZJOeOS8DM43rXbp4AZo1n9zCU2qjpcRko0b6/QJi9w=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
|
||||
github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
|
||||
github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c=
|
||||
github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
|
||||
github.com/hashicorp/go-retryablehttp v0.7.5 h1:bJj+Pj19UZMIweq/iie+1u5YCdGrnxCT9yvm0e+Nd5M=
|
||||
github.com/hashicorp/go-retryablehttp v0.7.5/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8=
|
||||
github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k=
|
||||
github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
|
||||
github.com/hashicorp/go-retryablehttp v0.7.7 h1:C8hUCYzor8PIfXHa4UrZkU4VvK8o9ISHxT2Q8+VepXU=
|
||||
github.com/hashicorp/go-retryablehttp v0.7.7/go.mod h1:pkQpWZeYWskR+D1tR2O5OcBFOxfA7DoAO6xtkuQnHTk=
|
||||
github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek=
|
||||
github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
||||
github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY=
|
||||
github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
||||
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
|
||||
@ -156,34 +130,32 @@ github.com/lithammer/fuzzysearch v1.1.8 h1:/HIuJnjHuXS8bKaiTMeeDlW2/AyIWk2brx1V8
|
||||
github.com/lithammer/fuzzysearch v1.1.8/go.mod h1:IdqeyBClc3FFqSzYq/MXESsS4S0FsZ5ajtkr5xPLts4=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
|
||||
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
|
||||
github.com/magiconair/properties v1.8.9 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM=
|
||||
github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
|
||||
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
|
||||
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
|
||||
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
||||
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/mmcloughlin/avo v0.6.0 h1:QH6FU8SKoTLaVs80GA8TJuLNkUYl4VokHKlPhVDg4YY=
|
||||
github.com/mmcloughlin/avo v0.6.0/go.mod h1:8CoAGaCSYXtCPR+8y18Y9aB/kxb8JSS6FRI7mSkvD+8=
|
||||
github.com/nsf/termbox-go v1.1.1 h1:nksUPLCb73Q++DwbYUBEglYBRPZyoXJdrj5L+TkjyZY=
|
||||
github.com/nsf/termbox-go v1.1.1/go.mod h1:T0cTdVuOwf7pHQNtfhnEbzHbcNyCEcVU4YPpouCbVxo=
|
||||
github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI=
|
||||
github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M=
|
||||
github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k=
|
||||
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
|
||||
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
|
||||
github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY=
|
||||
github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
|
||||
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
|
||||
github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4=
|
||||
github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI=
|
||||
github.com/pjbgf/sha1cd v0.3.1 h1:Dh2GYdpJnO84lIw0LJwTFXjcNbasP/bklicSznyAaPI=
|
||||
github.com/pjbgf/sha1cd v0.3.1/go.mod h1:Y8t7jSB/dEI/lQE04A1HVKteqjj9bX5O4+Cex0TCu8s=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
@ -196,8 +168,6 @@ github.com/pterm/pterm v0.12.31/go.mod h1:32ZAWZVXD7ZfG0s8qqHXePte42kdz8ECtRyEej
|
||||
github.com/pterm/pterm v0.12.33/go.mod h1:x+h2uL+n7CP/rel9+bImHD5lF3nM9vJj80k9ybiiTTE=
|
||||
github.com/pterm/pterm v0.12.36/go.mod h1:NjiL09hFhT/vWjQHSj1athJpx6H8cjpHXNAK5bUw8T8=
|
||||
github.com/pterm/pterm v0.12.40/go.mod h1:ffwPLwlbXxP+rxT0GsgDTzS3y3rmpAO1NMjUkGTYf8s=
|
||||
github.com/pterm/pterm v0.12.79 h1:lH3yrYMhdpeqX9y5Ep1u7DejyHy7NSQg9qrBjF9dFT4=
|
||||
github.com/pterm/pterm v0.12.79/go.mod h1:1v/gzOF1N0FsjbgTHZ1wVycRkKiatFvJSJC4IGaQAAo=
|
||||
github.com/pterm/pterm v0.12.80 h1:mM55B+GnKUnLMUSqhdINe4s6tOuVQIetQ3my8JGyAIg=
|
||||
github.com/pterm/pterm v0.12.80/go.mod h1:c6DeF9bSnOSeFPZlfs4ZRAFcf5SCoTwvwQ5xaKGQlHo=
|
||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
@ -206,9 +176,8 @@ github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
|
||||
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
|
||||
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ=
|
||||
github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4=
|
||||
github.com/sagikazarmark/locafero v0.6.0 h1:ON7AQg37yzcRPU69mt7gwhFEBwxI6P9T4Qu3N51bwOk=
|
||||
github.com/sagikazarmark/locafero v0.6.0/go.mod h1:77OmuIc6VTraTXKXIs/uvUxKGUXjE1GbemJYHqdNjX0=
|
||||
github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
|
||||
@ -217,53 +186,31 @@ github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNX
|
||||
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
|
||||
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
|
||||
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||
github.com/skeema/knownhosts v1.2.2 h1:Iug2P4fLmDw9f41PB6thxUkNUkJzB5i+1/exaj40L3A=
|
||||
github.com/skeema/knownhosts v1.2.2/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo=
|
||||
github.com/skeema/knownhosts v1.3.0 h1:AM+y0rI04VksttfwjkSTNQorvGqmwATnvnAHpSgc0LY=
|
||||
github.com/skeema/knownhosts v1.3.0/go.mod h1:sPINvnADmT/qYH1kfv+ePMmOBTH6Tbl7b5LvTDjFK7M=
|
||||
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
|
||||
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
|
||||
github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
|
||||
github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY=
|
||||
github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0=
|
||||
github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
|
||||
github.com/spf13/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w=
|
||||
github.com/spf13/cast v1.7.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
|
||||
github.com/spf13/cast v1.7.1 h1:cuNEagBQEHWN1FnbGEjCXL2szYEXqfJPbP2HNUaca9Y=
|
||||
github.com/spf13/cast v1.7.1/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
|
||||
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
|
||||
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
|
||||
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
|
||||
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spf13/viper v1.18.2 h1:LUXCnvUvSM6FXAsj6nnfc8Q2tp1dIgUfY9Kc8GsSOiQ=
|
||||
github.com/spf13/viper v1.18.2/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk=
|
||||
github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI=
|
||||
github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
|
||||
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
|
||||
github.com/whilp/git-urls v1.0.0 h1:95f6UMWN5FKW71ECsXRUd3FVYiXdrE7aX4NZKcPmIjU=
|
||||
github.com/whilp/git-urls v1.0.0/go.mod h1:J16SAmobsqc3Qcy98brfl5f5+e0clUvg1krgwk/qCfE=
|
||||
github.com/xanzy/go-gitlab v0.104.1 h1:g/liXIPJH0jsTwVuzTAUMiKdTf6Qup3u2XZq5Rp90Wc=
|
||||
github.com/xanzy/go-gitlab v0.104.1/go.mod h1:ETg8tcj4OhrB84UEgeE8dSuV/0h4BBL1uOV/qK0vlyI=
|
||||
github.com/xanzy/go-gitlab v0.109.0 h1:RcRme5w8VpLXTSTTMZdVoQWY37qTJWg+gwdQl4aAttE=
|
||||
github.com/xanzy/go-gitlab v0.109.0/go.mod h1:wKNKh3GkYDMOsGmnfuX+ITCmDuSDWFO0G+C4AygL9RY=
|
||||
github.com/xanzy/go-gitlab v0.113.0 h1:v5O4R+YZbJGxKqa9iIZxjMyeKkMKBN8P6sZsNl+YckM=
|
||||
github.com/xanzy/go-gitlab v0.113.0/go.mod h1:wKNKh3GkYDMOsGmnfuX+ITCmDuSDWFO0G+C4AygL9RY=
|
||||
github.com/xanzy/go-gitlab v0.115.0 h1:6DmtItNcVe+At/liXSgfE/DZNZrGfalQmBRmOcJjOn8=
|
||||
github.com/xanzy/go-gitlab v0.115.0/go.mod h1:5XCDtM7AM6WMKmfDdOiEpyRWUqui2iS9ILfvCZ2gJ5M=
|
||||
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
|
||||
@ -279,51 +226,29 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
|
||||
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
|
||||
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
|
||||
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
|
||||
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
||||
golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
|
||||
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
|
||||
golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ=
|
||||
golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg=
|
||||
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
|
||||
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
|
||||
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM=
|
||||
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
|
||||
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 h1:e66Fs6Z+fZTbFBAxKfP3PALWBtpfqks2bwGcexMxgtk=
|
||||
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0/go.mod h1:2TbTHSBQa924w8M6Xs1QcRcFwyucIwBGpK1p2f1YFFY=
|
||||
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f h1:XdNn9LlyWAhLVp6P/i8QYBW+hlyhrhei9uErw2B5GJo=
|
||||
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f/go.mod h1:D5SMRVC3C2/4+F/DB1wZsLRnSNimn2Sp/NPsCrsv8ak=
|
||||
golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 h1:1UoZQm6f0P/ZO0w1Ri+f+ifG/gXhegadRdwBIXEFWDo=
|
||||
golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67/go.mod h1:qj5a5QZpwLU2NLQudwIN5koi3beDhSAlJwa67PuM98c=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
|
||||
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
|
||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
|
||||
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
|
||||
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
||||
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
|
||||
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
|
||||
golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo=
|
||||
golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM=
|
||||
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
|
||||
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
|
||||
golang.org/x/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo=
|
||||
golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
|
||||
golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs=
|
||||
golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
|
||||
golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE=
|
||||
golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
|
||||
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
@ -338,62 +263,35 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
|
||||
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
|
||||
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
|
||||
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
|
||||
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
|
||||
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
||||
golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw=
|
||||
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
|
||||
golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
|
||||
golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
|
||||
golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU=
|
||||
golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E=
|
||||
golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q=
|
||||
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
|
||||
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
|
||||
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
|
||||
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
|
||||
golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4=
|
||||
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
|
||||
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
||||
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
|
||||
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||
golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U=
|
||||
golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||
golang.org/x/time v0.8.0 h1:9i3RxcPv3PZnitoVGMPDKZSq1xW1gK1Xy3ArNOGZfEg=
|
||||
golang.org/x/time v0.8.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/tools v0.28.0 h1:WuB6qZ4RPCQo5aP3WdKZS7i595EdWqWR8vqJTlwTVK8=
|
||||
golang.org/x/tools v0.28.0/go.mod h1:dcIOrVd3mfQKTgrDVQHqCPMWy6lnhfhtX3hLXYVLfRw=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
|
36
internal/cache/cache.go
vendored
36
internal/cache/cache.go
vendored
@ -7,12 +7,15 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/pterm/pterm"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/config"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/projects"
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/config"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/projects"
|
||||
)
|
||||
|
||||
const cacheVersion = "v0.1.0"
|
||||
|
||||
type Cache struct {
|
||||
Projects []*projects.Project
|
||||
Aliases []*ProjectAlias
|
||||
@ -26,6 +29,7 @@ type Cache struct {
|
||||
file string
|
||||
log *pterm.Logger
|
||||
path string
|
||||
CacheVersion string
|
||||
}
|
||||
|
||||
type CacheOpts struct {
|
||||
@ -65,12 +69,11 @@ func (c *Cache) LockCache() {
|
||||
c.log.Info("Attempting to lock cache")
|
||||
c.checkLock()
|
||||
|
||||
file, err := os.OpenFile(c.file+".lock", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0640)
|
||||
defer file.Close()
|
||||
|
||||
file, err := os.OpenFile(c.file+".lock", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o640)
|
||||
if err != nil {
|
||||
c.log.Fatal("Failed to lock cache", c.log.Args("error", err))
|
||||
}
|
||||
file.Close()
|
||||
}
|
||||
|
||||
func (c *Cache) checkLock() {
|
||||
@ -81,7 +84,7 @@ func (c *Cache) checkLock() {
|
||||
|
||||
// Saves the current state of the cache to disk
|
||||
func (c *Cache) write() {
|
||||
file, err := os.OpenFile(c.file, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0640)
|
||||
file, err := os.OpenFile(c.file, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o640)
|
||||
if err != nil {
|
||||
c.log.Error("Failed to write cache to disk", c.log.Args("error", err))
|
||||
}
|
||||
@ -92,6 +95,7 @@ func (c *Cache) write() {
|
||||
c.log.Debug("Cache saved to disk")
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Cache) Write() {
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
@ -117,6 +121,19 @@ func (c *Cache) Read() error {
|
||||
d := yaml.NewDecoder(file)
|
||||
d.Decode(c)
|
||||
|
||||
// Perform migrations
|
||||
err, migrated := c.doMigrations()
|
||||
if err != nil {
|
||||
c.log.Error("Failed to run cache migrations",
|
||||
c.log.Args(
|
||||
"migrated", migrated,
|
||||
"error", err,
|
||||
))
|
||||
} else if migrated > 0 {
|
||||
c.log.Info("Migrations run successfully", c.log.Args(
|
||||
"migrated", migrated))
|
||||
}
|
||||
|
||||
c.readFromFile = true
|
||||
return nil
|
||||
}
|
||||
@ -132,6 +149,7 @@ func (c *Cache) clear(clearAliases bool) {
|
||||
}
|
||||
c.setUpdated()
|
||||
}
|
||||
|
||||
func (c *Cache) Clear(clearAliases bool) {
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
@ -148,7 +166,7 @@ func (c *Cache) refresh(remotes ...string) {
|
||||
c.LoadRemotes(remotes...)
|
||||
}
|
||||
|
||||
// Iterates through all GitLab projects the user has access to, updating
|
||||
// Iterates through all Git projects the user has access to, updating
|
||||
// the project cache where necessary
|
||||
func (c *Cache) Refresh(remotes ...string) {
|
||||
c.lock.Lock()
|
||||
@ -210,5 +228,5 @@ func NewProjectCache(opts *CacheOpts) (*Cache, error) {
|
||||
}
|
||||
|
||||
func createProjectCache(path string) error {
|
||||
return os.WriteFile(path, nil, 0640)
|
||||
return os.WriteFile(path, nil, 0o640)
|
||||
}
|
||||
|
25
internal/cache/cache_aliases.go
vendored
25
internal/cache/cache_aliases.go
vendored
@ -3,8 +3,9 @@ package cache
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/projects"
|
||||
"golang.org/x/exp/slices"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/projects"
|
||||
)
|
||||
|
||||
func (c *Cache) deleteAlias(alias *ProjectAlias) {
|
||||
@ -21,34 +22,35 @@ func (c *Cache) DeleteAlias(alias *ProjectAlias) {
|
||||
c.deleteAlias(alias)
|
||||
}
|
||||
|
||||
func (c *Cache) addAlias(alias string, projectID int, remote string) error {
|
||||
func (c *Cache) addAlias(alias string, project *projects.Project) error {
|
||||
if c.GetAliasByName(alias) != nil {
|
||||
return errors.New("Failed to add alias, already exists")
|
||||
return errors.New("failed to add alias, already exists")
|
||||
}
|
||||
|
||||
c.Aliases = append(c.Aliases,
|
||||
&ProjectAlias{
|
||||
Alias: alias,
|
||||
ProjectID: projectID,
|
||||
Remote: remote,
|
||||
ProjectID: project.ID,
|
||||
ID: project.GetID(),
|
||||
Remote: project.Remote,
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Cache) AddAlias(alias string, projectID int, remote string) error {
|
||||
func (c *Cache) AddAlias(alias string, project *projects.Project) error {
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
return c.addAlias(alias, projectID, remote)
|
||||
return c.addAlias(alias, project)
|
||||
}
|
||||
|
||||
func (c *Cache) GetProjectsWithAliases() []*projects.Project {
|
||||
projectList := make([]*projects.Project, 0)
|
||||
projectsFound := make([]int, 0)
|
||||
projectsFound := make([]string, 0)
|
||||
for _, a := range c.Aliases {
|
||||
if !slices.Contains(projectsFound, a.ProjectID) {
|
||||
if !slices.Contains(projectsFound, a.ID) {
|
||||
projectList = append(projectList, c.GetProjectByAlias(a))
|
||||
projectsFound = append(projectsFound, a.ProjectID)
|
||||
projectsFound = append(projectsFound, a.ID)
|
||||
}
|
||||
}
|
||||
return projectList
|
||||
@ -67,12 +69,13 @@ func (c *Cache) setAliasRemotes() {
|
||||
}
|
||||
|
||||
func (c *Cache) setAliasRemote(alias *ProjectAlias) {
|
||||
project := c.GetProjectByID(alias.ProjectID)
|
||||
project := c.GetProjectByID(alias.ID)
|
||||
if project != nil {
|
||||
alias.Remote = project.Remote
|
||||
c.log.Debug("Fixed missing alias remote", c.log.Args(
|
||||
"alias", alias.Alias,
|
||||
"projectID", alias.ProjectID,
|
||||
"ID", alias.ID,
|
||||
"remote", alias.Remote,
|
||||
))
|
||||
}
|
||||
|
6
internal/cache/cache_load.go
vendored
6
internal/cache/cache_load.go
vendored
@ -5,9 +5,9 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/pterm/pterm"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/load"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/remote"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/load"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/remote"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
|
78
internal/cache/cache_migrations.go
vendored
Normal file
78
internal/cache/cache_migrations.go
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"golang.org/x/mod/semver"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/projects"
|
||||
)
|
||||
|
||||
// Migrations funcs should return errors along with
|
||||
// number of records updated
|
||||
type migrationFunc func(c *Cache) (error, int)
|
||||
|
||||
// Registry of migrations by version
|
||||
var migrations = map[string]map[string]migrationFunc{
|
||||
"v0.1.0": {
|
||||
"Make Aliases Unique": v010_aliases,
|
||||
},
|
||||
}
|
||||
|
||||
// Performs any required updates based on version
|
||||
// of cache read from disk.
|
||||
// Does not check to ensure migrations were successful,
|
||||
// only checks if a version has been achieved
|
||||
func (c *Cache) DoMigrations() (error, int) {
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
return c.doMigrations()
|
||||
}
|
||||
|
||||
func (c *Cache) doMigrations() (error, int) {
|
||||
var errs error
|
||||
var migrated int
|
||||
for version, migrationFuncs := range migrations {
|
||||
var funcMigrated int
|
||||
if semver.Compare(c.CacheVersion, version) < 0 {
|
||||
for name, migration := range migrationFuncs {
|
||||
err, numMigrated := migration(c)
|
||||
if err != nil {
|
||||
errs = errors.Join(
|
||||
errs,
|
||||
fmt.Errorf("%s - %s: %w", version, name, err),
|
||||
)
|
||||
}
|
||||
funcMigrated += numMigrated
|
||||
}
|
||||
|
||||
// We've reached a cache version, update the CacheVersion
|
||||
// and write to disk
|
||||
if errs == nil && funcMigrated > 0 {
|
||||
c.CacheVersion = version
|
||||
c.write()
|
||||
}
|
||||
}
|
||||
migrated += funcMigrated
|
||||
}
|
||||
|
||||
return errs, migrated
|
||||
}
|
||||
|
||||
func v010_aliases(c *Cache) (error, int) {
|
||||
var aliasesMigrated int
|
||||
var errs error
|
||||
for i, a := range c.Aliases {
|
||||
if a.ID == "" {
|
||||
if a.Remote == "" {
|
||||
errs = errors.Join(errs,
|
||||
fmt.Errorf("alias %s [id:%d] has no remote", a.Alias, a.ProjectID))
|
||||
continue
|
||||
}
|
||||
c.Aliases[i].ID = projects.MakeID(a.Remote, a.ProjectID)
|
||||
aliasesMigrated++
|
||||
}
|
||||
}
|
||||
return errs, aliasesMigrated
|
||||
}
|
2
internal/cache/cache_projects.go
vendored
2
internal/cache/cache_projects.go
vendored
@ -4,7 +4,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/pterm/pterm"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/projects"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/projects"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
|
2
internal/cache/fuzz.go
vendored
2
internal/cache/fuzz.go
vendored
@ -6,7 +6,7 @@ import (
|
||||
"github.com/lithammer/fuzzysearch/fuzzy"
|
||||
"golang.org/x/exp/slices"
|
||||
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/projects"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/projects"
|
||||
)
|
||||
|
||||
// Performs a fuzzy find on the input string, returning the closest
|
||||
|
7
internal/cache/projects.go
vendored
7
internal/cache/projects.go
vendored
@ -4,8 +4,9 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/pterm/pterm"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/projects"
|
||||
"golang.org/x/exp/slices"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/projects"
|
||||
)
|
||||
|
||||
func (c *Cache) ProjectString(p *projects.Project) string {
|
||||
@ -60,9 +61,9 @@ func (c *Cache) GetProjectByRemoteAndId(remote string, id int) *projects.Project
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Cache) GetProjectByID(id int) *projects.Project {
|
||||
func (c *Cache) GetProjectByID(id string) *projects.Project {
|
||||
for _, p := range c.Projects {
|
||||
if p.ID == id {
|
||||
if p.GetID() == id {
|
||||
return p
|
||||
}
|
||||
}
|
||||
|
6
internal/cache/projects_alias.go
vendored
6
internal/cache/projects_alias.go
vendored
@ -7,13 +7,15 @@ import (
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/pterm/pterm"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/projects"
|
||||
"golang.org/x/exp/slices"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/projects"
|
||||
)
|
||||
|
||||
type ProjectAlias struct {
|
||||
Alias string
|
||||
ProjectID int
|
||||
ID string
|
||||
Remote string
|
||||
}
|
||||
|
||||
@ -96,7 +98,7 @@ func (c *Cache) GetProjectByAlias(alias *ProjectAlias) *projects.Project {
|
||||
return nil
|
||||
}
|
||||
for _, p := range c.Projects {
|
||||
if p.ID == alias.ProjectID && p.Remote == alias.Remote {
|
||||
if p.GetID() == alias.ID {
|
||||
return p
|
||||
}
|
||||
}
|
||||
|
4
internal/cache/projects_fs.go
vendored
4
internal/cache/projects_fs.go
vendored
@ -6,7 +6,7 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/projects"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/projects"
|
||||
)
|
||||
|
||||
func (c *Cache) GoTo(project *projects.Project) {
|
||||
@ -32,7 +32,7 @@ func (c *Cache) GetProjectFromCwd() (*projects.Project, error) {
|
||||
if err != nil {
|
||||
return project, err
|
||||
} else if !strings.HasPrefix(cwd, c.path) {
|
||||
return project, errors.New("Not in any project path")
|
||||
return project, errors.New("not in any project path")
|
||||
}
|
||||
|
||||
// Strip projects dir from path
|
||||
|
5
internal/cache/projects_git.go
vendored
5
internal/cache/projects_git.go
vendored
@ -5,7 +5,8 @@ import (
|
||||
"time"
|
||||
|
||||
git "github.com/go-git/go-git/v5"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/projects"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/projects"
|
||||
)
|
||||
|
||||
const gitCloneTimeoutSecs = 60
|
||||
@ -31,7 +32,7 @@ func (c *Cache) OpenProject(ctx context.Context, project *projects.Project) *git
|
||||
// Check to make sure we can connect before we time out
|
||||
// shouldn't be necessary, but go-git does not properly
|
||||
// honor its context
|
||||
if err := project.CheckHost(projects.GitProtoSSH); err != nil {
|
||||
if err = project.CheckHost(projects.GitProtoSSH); err != nil {
|
||||
c.log.Fatal("Git remote unreachable, giving up", c.log.Args("error", err))
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ package config
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/info"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/info"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"net/url"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/info"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/info"
|
||||
)
|
||||
|
||||
type GiteaRemote struct {
|
||||
|
@ -7,8 +7,8 @@ import (
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/projects"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/remote"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/projects"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/remote"
|
||||
)
|
||||
|
||||
func (r *GiteaRemote) ReposToProjects(repos []*gitea.Repository) []*projects.Project {
|
||||
|
@ -4,8 +4,8 @@ import (
|
||||
"errors"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/load"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/remote"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/load"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/remote"
|
||||
)
|
||||
|
||||
const giteaReposPerPage = 20
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/google/go-github/v58/github"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/info"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/info"
|
||||
)
|
||||
|
||||
type GithubRemote struct {
|
||||
|
@ -4,8 +4,8 @@ import (
|
||||
"math"
|
||||
|
||||
"github.com/google/go-github/v58/github"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/projects"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/remote"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/projects"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/remote"
|
||||
)
|
||||
|
||||
func (r *GithubRemote) GetNumProjects(opts *remote.RemoteQueryOpts) int {
|
||||
|
@ -4,8 +4,8 @@ import (
|
||||
"errors"
|
||||
|
||||
"github.com/google/go-github/v58/github"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/load"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/remote"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/load"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/remote"
|
||||
)
|
||||
|
||||
const githubReposPerPage = 20
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/xanzy/go-gitlab"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/info"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/info"
|
||||
)
|
||||
|
||||
type GitlabRemote struct {
|
||||
|
@ -5,9 +5,9 @@ import (
|
||||
|
||||
"github.com/pterm/pterm"
|
||||
"github.com/xanzy/go-gitlab"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/info"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/projects"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/remote"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/info"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/projects"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/remote"
|
||||
)
|
||||
|
||||
var DefaultListOpts = &gitlab.ListProjectsOptions{
|
||||
|
@ -4,8 +4,8 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/xanzy/go-gitlab"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/load"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/remote"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/load"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/remote"
|
||||
)
|
||||
|
||||
// Will determine number of total projects,
|
||||
|
@ -1,6 +1,6 @@
|
||||
package load
|
||||
|
||||
import "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/projects"
|
||||
import "gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/projects"
|
||||
|
||||
// This package provides structs that serve
|
||||
// as the interface between remotes, and any code
|
||||
|
@ -1,6 +1,7 @@
|
||||
package projects
|
||||
|
||||
import (
|
||||
"crypto/sha1"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
@ -8,6 +9,8 @@ import (
|
||||
"github.com/go-git/go-git/v5"
|
||||
)
|
||||
|
||||
// Git project metadata
|
||||
// Do not use Project.ID directly (remotes may conflict), use Project.GetID()
|
||||
type Project struct {
|
||||
ID int
|
||||
Description string
|
||||
@ -35,8 +38,7 @@ type ProjectLanguage struct {
|
||||
}
|
||||
|
||||
func NewProjectLanguages() *ProjectLanguages {
|
||||
var pLangs ProjectLanguages
|
||||
pLangs = make([]*ProjectLanguage, 0)
|
||||
var pLangs ProjectLanguages = make([]*ProjectLanguage, 0)
|
||||
return &pLangs
|
||||
}
|
||||
|
||||
@ -44,6 +46,32 @@ func (pl *ProjectLanguages) AddLanguage(lang *ProjectLanguage) {
|
||||
*pl = append(*pl, lang)
|
||||
}
|
||||
|
||||
// Gets a unique ID using a short-sha of the http repo
|
||||
// along with the numerical ID of the project.
|
||||
// Uses SSH URL and then Remote if previous is empty
|
||||
func (p *Project) GetID() string {
|
||||
return fmt.Sprintf("%s||%d", p.GetRemoteSha(), p.ID)
|
||||
}
|
||||
|
||||
func MakeID(remote string, projectID int) string {
|
||||
return fmt.Sprintf("%s||%d", GetRemoteSha(remote), projectID)
|
||||
}
|
||||
|
||||
func (p *Project) GetRemoteSha() string {
|
||||
remote := p.Remote
|
||||
if remote == "" && p.HTTPURLToRepo != "" {
|
||||
remote = p.HTTPURLToRepo
|
||||
} else if remote == "" && p.WebURL != "" {
|
||||
remote = p.WebURL
|
||||
}
|
||||
|
||||
return GetRemoteSha(remote)
|
||||
}
|
||||
|
||||
func GetRemoteSha(remote string) string {
|
||||
return fmt.Sprintf("%x", sha1.Sum([]byte(remote)))[:12]
|
||||
}
|
||||
|
||||
func (p *Project) String() string {
|
||||
var projectString string
|
||||
if p != nil {
|
||||
|
@ -23,7 +23,7 @@ func (p *Project) GetGitInfo() string {
|
||||
commit, _ := repo.CommitObject(head.Hash())
|
||||
str += "\n" + commit.String()
|
||||
|
||||
str += pterm.LightMagenta("GitLab: ") + pterm.Bold.Sprint(p.HTTPURLToRepo) + "\n"
|
||||
str += pterm.LightMagenta("Git: ") + pterm.Bold.Sprint(p.HTTPURLToRepo) + "\n"
|
||||
|
||||
if remotes, _ := repo.Remotes(); len(remotes) > 0 {
|
||||
str += pterm.LightBlue("Remote: ") + pterm.Bold.Sprint(remotes[0].Config().URLs[0])
|
||||
|
@ -20,9 +20,7 @@ const (
|
||||
GitProtoHTTP
|
||||
)
|
||||
|
||||
var (
|
||||
ErrUnknownHost error = errors.New("No addresses found for host")
|
||||
)
|
||||
var ErrUnknownHost error = errors.New("no addresses found for host")
|
||||
|
||||
func (p *Project) CheckHost(proto GitProto) error {
|
||||
switch proto {
|
||||
@ -31,7 +29,7 @@ func (p *Project) CheckHost(proto GitProto) error {
|
||||
case GitProtoSSH:
|
||||
return p.checkSSHRemote()
|
||||
}
|
||||
return errors.New("Unknown git protocol")
|
||||
return errors.New("unknown git protocol")
|
||||
}
|
||||
|
||||
func (p *Project) checkHTTPRemote() error {
|
||||
|
@ -6,8 +6,8 @@ import (
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/info"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/load"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/info"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/load"
|
||||
)
|
||||
|
||||
const defNetDialTimeoutSecs = 3
|
||||
|
@ -3,9 +3,9 @@ package remotes
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/load"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/projects"
|
||||
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/remote"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/load"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/projects"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/remote"
|
||||
)
|
||||
|
||||
// Will determine number of total projects,
|
||||
|
Reference in New Issue
Block a user