Categorygithub.com/sascha-andres/devenv
modulepackage
1.6.0
Repository: https://github.com/sascha-andres/devenv.git
Documentation: pkg.go.dev

# README

devenv

devenv is a tool to manage projects containing multiple git repositories. With a config you can setup all repositories with one command and even work with the local repositories as if they where one ( eg creating branches in all referenced projects) using the shell.

Go Report Card codebeat badge

Prerequisites

You have to have a working git commandline installation.

Known caveats

Developed and mostly tested under Linux. OSX and Windows are currently not thoroughly tested.

Commands to be executed before a bash is called is unsupported on Windows.

A shell must be configured for Windows.

Main configuration

There are two main configuration options:

  1. basepath
  2. configpath

Those values can either be set in your home directory in a .devenv.[yaml,toml,json] file, in the current directory or as environment variables.

A sample yaml file looks like this:

---

basepath: /dev/src
configpath: /home/user/.devenv

This project uses viper for configuration and commandline argument handling.

basepath

This is the path in which projects are created. E setup project creates a folder within and checks out the connected repositories relative to that directory.

configpath

Where to store the project specific configurations.

Project configuration

The project configuration contains references to the repositories and basic settings for the environment:

  1. name
  2. repositories
  3. env
  4. shell
  5. commands

A valid project configuration looks like this:

---

name: devenv
repositories:
  - name: devenv
    url: [email protected]:sascha-andres/devenv.git
    path: src/devenv
processes:
  shell: bash
  commands:
    - echo Hello
  env:
    VAR: VALUE

name

Name must be a unique name for your project. It is used to identify the project configuration in devenv calls.

repositories

A list of repositories. Each repository must provide the following information:

  1. name
  2. path
  3. url

A valid repository entry looks like this:

name: devenv
path: src/devenv
url: [email protected]:sascha-andres/devenv.git

name

Is used to identify the repository for operations specific to one repository

path

A relative path where the repository is cloned to

url

Remote url to the repository

External process configuration

env

Key value pairs that are added to the shell and git processes

shell

Executable fot the shell. If you want to use the fish shell in one project as opposed to your default shell specify here.

shellarguments

Passed to the shell as arguments

commands

Commands to execute before the shell is called.

Variables

Each environment variable known to the devenv process can be access as go standard template in the following places:

  • commands
  • shell
  • shell-arguments
  • Environment variables for processes

Values in env override the environment variables. An additional variable called ENV_DIRECTORY is provided containing the path to the environment.

While technically possible to inject references this is not supported!

Commands

Commands are top level commands to work with devenv itself. The following commands exist:

  • add
  • shell
  • clean
  • setup
  • list

Interactive shell

Breaking change in 1.3.0

Call devenv -- <environment> to start the interactive shell. With devenv shell <environment> the bash shell or configured shell will be called.

For commands see In-App shell

list

List all repositories in an environment:

devenv list <environment name>

add

Create a new project stub:

devenv add project

This will create a new configuration in your configuration directory.

shell

Open a system shell in the project directory with environment variables preconfigured.

You might add a --force flag to remove even though uncommitted changes exist.

Please make sure you synced with your remotes!!

clean

Remove project from basepath. Checks for uncommitted changes.

fetch

Info
Aliasesf
DescriptionRun a git fetch on all repositories

setup

Create project directory and clone all referenced projects. If your definition contains disabled projects, those will not be pulled.

version

Call to have the version printed out

In-App shell

The in app shell provides easy methods to work with your git repositories. Non aliases are part of autocompletion

shell command

Info
Aliasesnone
DescriptionOpens an operating system shell at the project root directory

Call with

shell

addrepo command

Info
Aliasesnone
DescriptionWill ask for the required values of a repository and if cloning is successful saves the new repository to the project configuration

Call with

addrepo

Required information:

  • name
  • path
  • url

branch

Info
Aliasesbr
DescriptionWill switch to the specified branch for each repository
If the branch does not exist, it will be created

Call with

branch <name>

You can add any number of additional arguments as long as they are valid arguments to git checkout

Required information:

  • name

delrepo command

Info
Aliasesnone
DescriptionWill ask for the name of a repository and remove it from project when there are no changes

Call with

delrepo <name>

Required information:

  • name

log command

Info
Aliasesl
DescriptionPrints out the last ten commits decorated for each repository

Call with

log

pull command

Info
Aliases<
DescriptionExecutes a pull for each repository

Call with

pull

You can add any number of additional arguments as long as they are valid arguments to git pull

push command

Info
Aliases>
DescriptionExecutes a push for each repository

Call with

push

You can add any number of additional arguments as long as they are valid arguments to git push

status command

Info
Aliasesst
DescriptionPrints the status of each referenced repository

Call with

status

You can add any number of additional arguments as long as they are valid arguments to git status

scan

Info
DescriptionIterates over the directories within the projects path searching for git repositories

Call with

scan

rename

Info
DescriptionAllow renaming an environment

Call with

rename [old] -> [new]

Repository commands

Repository commands take the name of a repository as they work on a single repository and not on every referenced repository.

They are prefixed with repo which can be shortened to r.

The following commands are available for a single repository:

  • branch
  • commit
  • log
  • merge
  • pull
  • push
  • status
  • pin
  • unpin
  • shell
  • fetch

fetch

Runs a git fetch on the repository repositories

Info
Aliasesf
DescriptionRun a git fetch on the repository

shell command

Info
Aliasesnone
DescriptionOpens an operating system shell at the project root directory

Call with

repo shell

pin

Stores the current commit to the configuration.

  • Most actions are not performed on pinned repositories
  • On setup, a checkout on the specific commit will be done.

Call with

repo <name> pin

unpin

If pinned the repository will be unpinned and the specified branch will be checked out

Call with

repo <name> unpin <branch>

branch

Info
Aliasesbr
DescriptionWill switch to the specified branch for each repository
If the branch does not exist, it will be created

Call with

repo <name> branch <name-of-branch>

You can add any number of additional arguments as long as they are valid arguments to git checkout

Required information:

  • name
  • name-of-branch

log command

Info
Aliasesl
DescriptionPrints out the log for the repository

Call with

repo <name> log

Required information:

  • name

merge command

Info
Aliasesnone
DescriptionMerge a branch

Call with

repo <name> merge <branch-name>

You can add any number of additional arguments as long as they are valid arguments to git merge

Required information:

  • name

pull command

Info
Aliases<
DescriptionExecutes a pull

Call with

repo <name> pull

You can add any number of additional arguments as long as they are valid arguments to git pull

Required information:

  • name

push command

Info
Aliases>
DescriptionExecutes a push for repository

Call with

repo <name> push

You can add any number of additional arguments as long as they are valid arguments to git push

Required information:

  • name

status command

Info
Aliasesst
DescriptionPrints the status of repository

Call with

repo <name> status

You can add any number of additional arguments as long as they are valid arguments to git status

Required information:

  • name

Code of conduct

You can find the code of conduct here, taken from Contributor Covenant

History

VersionDescription
1.6.0use go.mod
allow rename of environment
script management
refactoring of file layout
1.5.1Reload list of repositories for autocomplete after adding a new one
1.5.0Disabled repositories are not cloned
Disable/Enable added to autocomplete
github.com/pkg/erros
v1.4.0Added shell command for interactive shell
v1.3.1Fix for push command
v1.3.0scan for repositories
pin repositories
shell command calls bash/os shell
-- calls interactive shell
v1.2.0Make log parameters configurable
Refactorings
v1.1.1Fix for branch detection
Refactorings
v1.1.0Completion for shell
Command arguments for shell
Variables
v1.0.1Enable/Disable repository
v1.0.0Initial version

# Packages

No description provided by the author

# Functions

ProjectIsCreated checks whether project is checked out.
PullConfiguration gets the latest commit from remote repository.
PushConfiguration puts the latest commit to remote repository.

# Structs

No description provided by the author
No description provided by the author
RepositoryConfiguration contains information about linked repositories.