git

package
v0.0.0-...-695a870 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Copyright © 2024 NAME HERE <EMAIL ADDRESS>

Copyright © 2024 NAME HERE <EMAIL ADDRESS>

Copyright © 2024 NAME HERE <EMAIL ADDRESS>

Copyright © 2024 NAME HERE <EMAIL ADDRESS>

Copyright © 2024 NAME HERE <EMAIL ADDRESS>

Copyright © 2024 NAME HERE <EMAIL ADDRESS>

Index

Constants

View Source
const DeleteProjectLock locker.LockFile = "/tmp/.goseq_project_delete.lock"

Variables

View Source
var GitCmd = &cobra.Command{
	Use:   "git",
	Short: "Open a note for a specyfied repo",
	Long: `Opens a note for the project if paths  not specyfied it finds the recent one
And the for the saved.You can see what Projects did u saved via the git list command`,
	Run: func(cmd *cobra.Command, args []string) {

		PROJECTS := viper.GetString("PROJECTS")
		if ProjectPath != "" {
			p := project.PickProject(ProjectPath)
			pAth := path.Join(p.Owner, p.Name)

			location := path.Join(PROJECTS, pAth)
			err := os.WriteFile(project.ENV_VAR, []byte(location), 0644)
			if err != nil {
				slog.Warn("Failed to read to the TMP file", "err", err)
			}
			return
		}
		if recent {
			if err := project.ReadRecent(false); err != nil {
				fmt.Println(err)
				os.Exit(1)
			}

		}
		if recent == false && ProjectPath == "" {
			cmd.Help()
		}

	},
}

gitCmd represents the git command

View Source
var ListCmd = &cobra.Command{
	Use:   "list",
	Short: "List added Projects and chose one to edit",
	Long: `It lists the projects that was previously added and lets you chose one.
The paths are located in $HOME/Documents/Agenda/projects/.PROJECTS_META.json `,
	Run: func(cmd *cobra.Command, args []string) {
		if err := project.ReadRecent(true); err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
	},
}

testCmd represents the test command

View Source
var PostCmd = &cobra.Command{
	Use:   "post",
	Short: "Post new issues to the github",
	Long:  `It scans the given direcories for githubissues  and post the ones that don't exist to the github`,
	Run: func(cmd *cobra.Command, args []string) {

		tokenValue := viper.Get("token")
		token, ok := tokenValue.(string)

		if !ok || token == "" {
			log.Fatal("Failed to found the Github Api token")
		}
		if ProjectPath != "" {
			p, err := project.NewProject(ProjectPath)
			if err != nil {
				log.Fatal(err)
			}
			if err := p.WalkProject(); err != nil {
				log.Fatal(err)
			}

			gitIssues, err := p.FetchGitHubIssues(token)
			if err != nil {
				log.Fatal(err)

			}
			p.ApplayIssues(token, &gitIssues)

		}

	},
}

postCmd represents the post command

View Source
var ProjectPath string
View Source
var ScanCmd = &cobra.Command{
	Use:   "scan",
	Short: "Scans todos from the given path",
	Long:  `Findes the project and prints all the todos founded inside the project/s `,
	Run: func(cmd *cobra.Command, args []string) {
		if ProjectPath != "" {
			prArray, err := project.ListProjects(ProjectPath)
			if err != nil {
				fmt.Println(err)
				os.Exit(1)
			}

			var wg sync.WaitGroup
			ctx := context.Background()
			sem := semaphore.NewWeighted(int64(10))

			for _, v := range prArray {
				wg.Add(1)
				go func(repo project.Project) {
					sem.Acquire(ctx, 1)
					defer wg.Done()
					sem.Release(1)
					if err := repo.WalkProject(); err != nil {
						fmt.Printf("Failed to scan %v, %v\n", repo.Name, err)
					}
					repo.PrintTodos()
				}(v)
			}

			wg.Wait()
			if len(prArray) != 0 && add {
				for _, p := range prArray {
					p.SaveProject()
				}
			}

		} else {
			cmd.Help()
		}
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL