gitfresh

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2024 License: MIT Imports: 16 Imported by: 0

README

GitFresh

A Developer Experience Tool to Keep Git local Repositories Updated 😎

Use Cases

Collaborative Software Development: In software development teams, multiple members may work on a shared project. Keeping local repositories updated ensures that everyone is working with the latest version of the code and reduces integration conflicts.

Frontend and Backend Integration: In a local integration environment, a frontend developer needs to keep their local repository updated with the latest changes from the develop backend API, which is being developed by a teammate, to ensure smooth integration.

Feel free to use the gitfresh tool for other scenarios as well!

Install

Gitfresh is available for MacOS and Linux via Homebrew.

First, you should install HomeBrew.

Then, run the following command:

brew install apolo96/tap/gitfresh

Check installation:

gitfresh version

Quickstart

GitFresh is a tool powered by Github and Ngrok.

I hope to add support to other git server providers in the future.

Requirements
  • Github Token
  • Ngrok Token

You can go to Github to create a new token with admin:repo_hook scope:

https://github.com/settings/tokens

You can go to Ngrok to get a personal token:

https://dashboard.ngrok.com/get-started/your-authtoken

Initialize Workspace

After installing GitFresh via Homebrew and getting GitHub and Ngrok tokens, then you can initialize a workspace:

First, go to the working directory that contains the Git repositories and run the following command:

gitfresh config

It opens the CLI Form where you should enter the GitHub and Ngrok tokens.

The TunnelDomain input is OPTIONAL, by default Ngrok generates a random DNS.

If you prefer, you can create a custom domain at: https://dashboard.ngrok.com/cloud-edge/domains.

Finally, run the following command:

gitfresh init

This command can take some seconds for startup services.

Add new repository

You can add new repositories to Gitfresh. Running the following command:

gitfresh scan

How It Works

GitFresh creates GitHub webhooks to send notifications of events git-push through an internet tunnel provided by Ngrok that triggers repository updates on the local machine (gitfresh agent)

Documentation

Index

Constants

View Source
const API_AGENT_HOST = "127.0.0.1:9191"
View Source
const APP_AGENT_FILE = "agent.txt"
View Source
const APP_AGENT_LOG_FILE = "agent-log.json"
View Source
const APP_CLI_LOG_FILE = "cli-log.json"
View Source
const APP_CONFIG_FILE_NAME = "config.json"
View Source
const APP_FOLDER = ".gitfresh"
View Source
const APP_GIT_PROVIDER = "github.com"
View Source
const APP_REPOS_FILE_NAME = "repositories.json"

Variables

This section is empty.

Functions

func ListRepository

func ListRepository() ([]byte, error)

func NewLogFile

func NewLogFile(name string) (io.Writer, func(), error)

func WebHookSecret

func WebHookSecret() string

Types

type APIPayload

type APIPayload struct {
	Ref        string        `json:"ref"`
	Repository APIRepository `json:"repository"`
	Commit     string        `json:"after"`
}

type APIRepository

type APIRepository struct {
	Name string `json:"name"`
}

type Agent

type Agent struct {
	ApiVersion   string `json:"api_version"`
	TunnelDomain string `json:"tunnel_domain"`
}

type AgentSvc

type AgentSvc struct {
	// contains filtered or unexported fields
}

Agent

func NewAgentSvc

func NewAgentSvc(l AppLogger, a OSCommander, f FlatFiler, c HttpClienter) *AgentSvc

func (AgentSvc) CheckAgentStatus

func (svc AgentSvc) CheckAgentStatus(tick *time.Ticker) (Agent, error)

func (AgentSvc) IsAgentRunning

func (svc AgentSvc) IsAgentRunning() (bool, error)

func (AgentSvc) SaveAgentPID

func (svc AgentSvc) SaveAgentPID(pid int) (int, error)

func (AgentSvc) StartAgent

func (svc AgentSvc) StartAgent() (int, error)

type AppConfig

type AppConfig struct {
	TunnelToken    string
	TunnelDomain   string
	GitServerToken string
	GitWorkDir     string
	GitHookSecret  string
}

type AppConfigSvc

type AppConfigSvc struct {
	// contains filtered or unexported fields
}

AppConfig

func NewAppConfigSvc

func NewAppConfigSvc(l AppLogger, f FlatFiler) *AppConfigSvc

func (AppConfigSvc) CreateConfigFile

func (svc AppConfigSvc) CreateConfigFile(config *AppConfig) error

func (AppConfigSvc) ReadConfigFile

func (svc AppConfigSvc) ReadConfigFile() (*AppConfig, error)

type AppLogger

type AppLogger interface {
	Info(msg string, args ...any)
	Error(msg string, args ...any)
	Warn(msg string, args ...any)
	Debug(msg string, args ...any)
	LogAttrs(ctx context.Context, level slog.Level, msg string, attrs ...slog.Attr)
}

type AppOS

type AppOS struct{}

func (AppOS) FindProgram

func (AppOS) FindProgram(pid int) (bool, error)

func (AppOS) LookProgram

func (AppOS) LookProgram(cmd string) (string, error)

func (AppOS) RunProgram

func (AppOS) RunProgram(path string, workdir string, args ...string) ([]byte, error)

func (AppOS) StartProgram

func (AppOS) StartProgram(path string, args ...string) (int, error)

func (AppOS) UserHomePath

func (AppOS) UserHomePath() (string, error)

func (AppOS) WalkDirFunc

func (AppOS) WalkDirFunc(path string, fn func(string)) error

type FlatFile

type FlatFile struct {
	Name string
	Path string
}

func (*FlatFile) Read

func (f *FlatFile) Read() (n []byte, err error)

func (*FlatFile) Write

func (f *FlatFile) Write(data []byte) (n int, err error)

type FlatFiler

type FlatFiler interface {
	Write(data []byte) (n int, err error)
	Read() (n []byte, err error)
}

type GitRepository

type GitRepository struct {
	Owner string
	Name  string
}

type GitRepositorySvc

type GitRepositorySvc struct {
	// contains filtered or unexported fields
}

GitRepository

func NewGitRepositorySvc

func NewGitRepositorySvc(l AppLogger, a OSDirCommand, f FlatFiler) *GitRepositorySvc

func (GitRepositorySvc) SaveRepositories

func (gr GitRepositorySvc) SaveRepositories(repos []*GitRepository) (n int, err error)

func (GitRepositorySvc) ScanRepositories

func (gr GitRepositorySvc) ScanRepositories(workdir string, gitProvider string) ([]*GitRepository, error)

type GitServerSvc

type GitServerSvc struct {
	// contains filtered or unexported fields
}

GitServer

func NewGitServerSvc

func NewGitServerSvc(l AppLogger, c HttpClienter) *GitServerSvc

func (GitServerSvc) CreateGitServerHook

func (svc GitServerSvc) CreateGitServerHook(repo *GitRepository, config *AppConfig) error

type HttpClienter

type HttpClienter interface {
	Do(req *http.Request) (*http.Response, error)
}

type OSCommander

type OSCommander interface {
	OSRunner
	OSPather
	StartProgram(path string, args ...string) (int, error)
	UserHomePath() (string, error)
	FindProgram(pid int) (bool, error)
}

type OSDirCommand

type OSDirCommand interface {
	OSRunner
	OSDirer
	OSPather
}

type OSDirer

type OSDirer interface {
	WalkDirFunc(path string, fn func(string)) error
}

type OSPather

type OSPather interface {
	LookProgram(cmd string) (string, error)
}

type OSRunner

type OSRunner interface {
	RunProgram(path string, workdir string, args ...string) ([]byte, error)
}

type Webhook

type Webhook struct {
	Name   string            `json:"name"`
	Active bool              `json:"active"`
	Events []string          `json:"events"`
	Config map[string]string `json:"config"`
}

Directories

Path Synopsis
cmd
api
cli

Jump to

Keyboard shortcuts

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