GithubHelp home page GithubHelp logo

garden-rs / garden Goto Github PK

View Code? Open in Web Editor NEW
63.0 63.0 9.0 3.65 MB

Garden grows and cultivates collections of Git trees ~ Official mirror of https://gitlab.com/garden-rs/garden

Home Page: https://garden-rs.gitlab.io

License: MIT License

Rust 98.96% Shell 0.27% Nix 0.77%
command-runner developer-tools git rust submodules worktree

garden's People

Contributors

davvid avatar dependabot[bot] avatar jordilin avatar jtietema avatar slackline avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

garden's Issues

Hide tree heading when cmd has no stdout/stderr

I have a use case that I haven't been able to figure out how to implement. I'd like to have a global command unpushed that goes through all my trees and prints out branch names for branches that aren't pushed upstream. I can list unpushed branches fine, but right now every tree gets a heading even if it doesn't have any unpushed branches. I'd like to be able to hide the headings for trees that don't have any unpushed branches. So for example:

# dev/advent-of-code
830b34d (incomplete-2021-19) Incomplete 2021-19
# dev/bitcurry-provisioning
# dev/cookiecutter-rust-bin
...

dev/advent-of-code has an unpushed branch so its heading should be listed, but dev/bitcurry-provisioning doesn't have any unpushed branches so I'd like to prevent having the heading printed.

If there's not a way to do this, no big deal, but I figured I'd ask! This is a really great tool by the way!

[wip] Feat: garden 'prune' command

Garden scans git repos [1] under management and removes them [2] to maintain sync with config and git-remote-prune, optionally prompting to first reconcile and ultimately to confirm.

In this way garden adheres the state of the managed repos on disk, to the state of the config+repo.


[1]
Apply to git-repos that were previously created by garden under a watched/managed directory, such as GARDEN_ROOT.
This may recommend that Garden annotate git repos with metadata to durably signal that it's providing lifecycle mgmt.

[2]
The repo is presently absent/removed from GARDEN_CONFIG or references a branch that's removed with a git remote prune.

includes duplicates rather than overrides

When using includes in the garden configuration file, I noticed that if two files are included and each contains the same command then when that command is run, it is run twice instead of once. This can be replicated by including the same config twice from different path locations. My expectation of the behavior was 'override' rather than 'duplicate'. I was hoping to use this feature for personal overrides on a department-provided configuration.

configure to not skip not existing tree on command

I'm growing my garden file with some backup commands to backup and restore from borg. As a test I'm trying to to restore from a borg backup, but trees that are not grown, are skipped for commands.

example:

variables:
  source: "${HOME}"
  storage: "${HOME}/projects/garden/storage"
  borg: "${HOME}/projects/garden/borg"
  borgname: borg
  borgsecret: secret
garden:
  root: "${HOME}"
templates:
  storage:
    url: "${source}/${TREE_NAME}"
    remotes:
      storage: "${storage}/${TREE_NAME}.git"
    commands:
      setup: |
        mkdir -p ${storage}
        git init --bare ${storage}/${TREE_NAME}.git
      push-storage: "git push storage \"$@\""
      push-var: "git push ${storage} \"$@\""
      borg-setup: |
        mkdir -p ${borg}/${TREE_NAME}
        BORG_PASSPHRASE=${borgsecret} borg init --append-only --encryption=repokey ${borg}/${TREE_NAME}
      borg-backup: |
        cd ${TREE_PATH}
        BORG_PASSPHRASE=${borgsecret} borg create ${borg}/${TREE_NAME}::{now} .
      borg-restore: |
        mkdir -p ${TREE_PATH}
        cd ${TREE_PATH}
        snapshot=$(BORG_PASSPHRASE=${borgsecret} borg list ${borg}/${TREE_NAME} --last 1 --short)
        BORG_PASSPHRASE=${borgsecret} borg extract ${borg}/${TREE_NAME}::$snapshot
      borg-check: |
        BORG_PASSPHRASE=${borgsecret} borg check ${borg}/${TREE_NAME}
trees:
  projects/garden/repo1:
    templates:
      - storage

If I do garden borg-restore projects/garden/repo1 it is skipped with # projects/garden/repo1 (skipped). Is there a way to override this skipping?

Now on NetBSD

Hi,

FYI, I've packaged garden for pkgsrc/NetBSD and merged the package into the main branch, http://mail-index.netbsd.org/pkgsrc-changes/2023/01/22/msg267560.html

This means users will be able to install garden from the official repositories using the native package manager, i.e. pkgin install garden

If users still prefer to build it from source, they can easily do that by

cd /usr/pkgsrc/devel/garden
make install

Regards

Integration tests fail in NixOS using nix-build

NixOS builds in sandboxed environments using nixbld users and /homeless-shelter as a $HOME. Those build users do not have .gitconfig setup, so git operations fail with error: could not lock config file /homeless-shelter/.gitconfig: No such file or directory. Complete output below after issuing nix build

     Running tests/integration_test.rs (target/release/deps/integration_test-74d13108bef44e11)

running 43 tests
test cmd_dot_default_no_args ... ok
test cmd_exec_grafted_group ... ok
test cmd_exec_garden_with_grafted_trees ... ok
test cmd_dot_default_double_dash_args ... ok
test cmd_exec_group_with_grafted_trees ... ok
test cmd_dot_default_double_dash ... ok
test cmd_dot_default_no_args_echo ... ok
test eval_config_dir_with_chdir_and_root ... ok
test cmd_no_errexit ... ok
test cmd_dash_dash_arguments_custom ... ok
test eval_exec_pwd_with_root_and_chdir ... ok
test eval_graft_variable_at_tree_scope ... ok
test eval_grafted_variable_at_global_scope ... ok
test eval_grafted_variable_with_namespace ... ok
test cmd_dash_dash_arguments ... ok
test eval_root_with_root ... ok
test cmd_shell_variables ... ok
test eval_root_with_root_and_chdir ... ok
test cmd_breadth_first_and_depth_first ... ok
test cmd_no_errexit_for_command_lists ... ok
test eval_grafted_builtin_variables ... ok
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
test cmd_prune_depth ... FAILED
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

test git_branches ... FAILED
fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

test eval_garden_config_dir ... FAILED
fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
test eval_override_variables ... FAILED
test git_worktree_details ... FAILED
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
test grow_bare_repo_with_config ... FAILED
test cmd_pre_and_post_commands ... ok
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
test grow_branches_for_clone ... FAILED
test grow_bare_repo ... FAILED
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
test grow_branch_default ... FAILED
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
test grow_clone ... FAILED
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
test grow_clone_shallow ... FAILED
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
test grow_clone_single_branch ... FAILED
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
test grow_default_remote_name ... FAILED
test grow_default_remote_url ... FAILED
test cmd_pre_and_post_nested_commands ... ok
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
test grow_gitconfig ... FAILED
test grow_gitconfig_append_value ... FAILED
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
test grow_symlinks ... FAILED
test grow_remotes ... FAILED
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
test grow_worktree_and_parent ... FAILED
test cmd_keep_going_and_no_errexit ... ok

failures:

---- cmd_prune_depth stdout ----
thread 'cmd_prune_depth' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- git_branches stdout ----
thread 'git_branches' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0

---- eval_garden_config_dir stdout ----
thread 'eval_garden_config_dir' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0

---- eval_override_variables stdout ----
thread 'eval_override_variables' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0

---- git_worktree_details stdout ----
thread 'git_worktree_details' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0

---- grow_bare_repo_with_config stdout ----
thread 'grow_bare_repo_with_config' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0

---- grow_branches_for_clone stdout ----
thread 'grow_branches_for_clone' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0

---- grow_bare_repo stdout ----
thread 'grow_bare_repo' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0

---- grow_branch_default stdout ----
thread 'grow_branch_default' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0

---- grow_clone stdout ----
thread 'grow_clone' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0

---- grow_clone_shallow stdout ----
thread 'grow_clone_shallow' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0

---- grow_clone_single_branch stdout ----
thread 'grow_clone_single_branch' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0

---- grow_default_remote_name stdout ----
thread 'grow_default_remote_name' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0

---- grow_default_remote_url stdout ----
thread 'grow_default_remote_url' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0

---- grow_gitconfig stdout ----
thread 'grow_gitconfig' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0

---- grow_gitconfig_append_value stdout ----
thread 'grow_gitconfig_append_value' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0

---- grow_symlinks stdout ----
thread 'grow_symlinks' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0

---- grow_remotes stdout ----
thread 'grow_remotes' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0

---- grow_worktree_and_parent stdout ----
thread 'grow_worktree_and_parent' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0


failures:
    cmd_prune_depth
    eval_garden_config_dir
    eval_override_variables
    git_branches
    git_worktree_details
    grow_bare_repo
    grow_bare_repo_with_config
    grow_branch_default
    grow_branches_for_clone
    grow_clone
    grow_clone_shallow
    grow_clone_single_branch
    grow_default_remote_name
    grow_default_remote_url
    grow_gitconfig
    grow_gitconfig_append_value
    grow_remotes
    grow_symlinks
    grow_worktree_and_parent

test result: FAILED. 24 passed; 19 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.09s

error: test failed, to rerun pass `--test integration_test`

Possible approaches I can think of:

  • Provide a gitconfig during the setup. Set up an env variable like GIT_CONFIG and GIT_CONFIG_NOSYSTEM so git commands make use of it. Believe env GIT_CONFIG is deprecated these days though.
  • I would not hard code expected $HOME values /home/test, such as https://github.com/davvid/garden/blob/main/tests/eval_test.rs#L201, so I'd set it up globally as const HOME: &'static str = "/home/test"; and use that as a reference.
  • NixOS nixbld users use HOME=/homeless-shelter (although that home does not actually exist) so using that would certainly fix all assertions and does not assume a home under a /home path

Completion error when no custom commands

Errors are returned using tab completion for cmd when no --commands option was provided to garden completion zsh. Other command completions appear to work. Command completion for cmd also appears to work without error after completions are generated with the --commands option. Reproduction steps:

$ uname -mrs
Darwin 21.6.0 x86_64

$ zsh --version
zsh 5.8.1 (x86_64-apple-darwin21.0)

$ garden --version
garden 0.5.0-beta

$ garden completion zsh > $DIR_IN_FPATH/_garden  # no --commands option given

$ garden cmd <tab>
_arguments:comparguments:325: doubled rest argument definition: *::arguments -- Arguments to forward to custom commands:
_arguments:comparguments:325: doubled rest argument definition: *::arguments -- Arguments to forward to custom commands:
_arguments:comparguments:325: doubled rest argument definition: *::arguments -- Arguments to forward to custom commands:

$ garden help <tab>
cmd         -- Run custom commands over gardens
completion  -- Generate shell completions
eval        -- Evaluate garden expressions
exec        -- Run commands inside garden environments
grow        -- Grow garden worktrees into existence
help        -- Print this message or the help of the given subcommand(s)
init        -- Initialize a "garden.yaml" garden configuration file
inspect     -- Query tree status
list        -- List available gardens, groups, trees and commands
plant       -- Add pre-existing worktrees to a garden configuration file
prune       -- Remove unreferenced Git repositories
shell       -- Open a shell in a garden environment

Available as Home-Manager Module

Hiya :)

Would you be open to enabling support for configuring and using Garden from Home-Manager [1], which is a declarative user-config manager within the Nix ecosystem?

I'd be interesting in contributing or supporting this with your guidance.

Home-Manager provides a wide array of configuration options [2] but nothing at all to manage git repos - in this way, it seems Garden and Home-Manager are extremely complementary to each other.

For my purposes, I'd like to use Home-Manager to install Garden, Push/Sync my Garden config file, and perhaps even (optionally) apply that garden config on login.

Happy to discuss more and thanks so much for the project!

[1] https://nix-community.github.io/home-manager/index.html
[2] https://nix-community.github.io/home-manager/options.html

Doc/Feat: Git-Worktree Support

Hello and thank you for garden!

I wonder if garden has support for https://git-scm.com/docs/git-worktree or could be extended to support them?
It's useful for me to checkout many worktrees which can get tricky when switching among different workspaces.

I'm still learning about Garden but I appreciate the sanity it brings this challenge and look forward to understanding and using it more over time.

is it possible to at start and end to a command

Scenario:

Let's say you have 5 tree in a group thats part of a garden. The name of the command you want to run is call" "Build". So you make a global command. Perfect!

When you go to run that command over the garden you first need to install something. Then after all the trees a built you want to uninstall something.

Is that possible?

$ garden Build

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.