gogit

package module
Version: v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2020 License: MIT Imports: 9 Imported by: 0

README

Local development with replace directives

Local development often involves local replace directives like

replace aduu.dev/utils => ../go/aduu-dev-utils

But tests fail when they are encountered on different build machines like Github Actions. To Avoid this I wrote this small script which can temporarily remove the local replacements, especially during git commits.

This avoids having to think about one last step before a push: removing local replace directives.

Install

go get aduu.dev/tools/gogit/gogitcmd/gogit

Examples

You are in a git repository root and you want to temporarily remove local go.mod replace directives during commit.

Automatically during commit

The replace commands can be installed into a pre-commit hook.

To install the git pre-commit and post-commit hooks:

gogit install-hooks .

What is basically being inserted is

.git/hooks/pre-commit:

#!/bin/bash

gogit replace .
git add go.mod

.git/hooks/post-commit

#!/bin/bash

gogit replace --undo .

The base command gogit can be replaced with a flag for install-hooks: --base-command=my-command

Manual

This way you can temporarily remove local replace directives:

gogit replace .

A backup is being written into "go.mod.b".

To reapply a backup:

gogit replace --undo .

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RemoveLocalReplacesFromGomod

func RemoveLocalReplacesFromGomod(arg string) (err error)

RemoveLocalReplacesFromGomod removes go.mod replace directives which are pointing to local folders.

func UndoRemovingLocalReplacesFromGomod

func UndoRemovingLocalReplacesFromGomod(arg string) (err error)

UndoRemovingLocalReplacesFromGomod replaces the local go.mod with the backup.

Types

This section is empty.

Source Files

Directories

Path Synopsis
gogit
Package main.
Package main.

Jump to

Keyboard shortcuts

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