TheLocehiliosan / yadm

Yet Another Dotfiles Manager
https://yadm.io/
GNU General Public License v3.0
4.94k stars 178 forks source link

Change behaviour of `yadm add -A` or introduce new sub `yadm all` to only add all files / directories added previously #364

Closed skwde closed 1 year ago

skwde commented 2 years ago

Is your feature request related to a problem? Please describe.

yadm add -A adds all files in $HOME. Thus one always has to explicitly do yadm add <changed file(s)> This is rather inconvenient and involves a lot of typing.

Describe the solution you'd like

yadm keeps track of the files or entire folders already added to the repository. We can already show the files yadm keeps track of via yadm list, this however only shows files. (And doesn't care if one did yadm add <some dir>) It would be nice if yadm add <some file or dir> writes this (<some file or dir>) also to a file when first, e.g. ~/.config/yadm/track when first added. Then yadm add -A is remapped to something like yadm add $(cat ~/.config/yadm/track).

Or if this is not possible because add comes from git, a new command something like yadm all would be a viable option I think.

Describe alternatives you've considered

I defined a wrapper function

# yadm add all wrapper
yadm() {
    if [[ $1 == 'add' ]] && [[ ${2:- } == '-A' || ${2:- } == '-all' ]]; then                
        #shellcheck disable=SC2046
        command yadm add $(cat ~/.config/yadm/track)
    else
        command yadm "$@"
    fi
} 

and keep ~/.config/yadm/track up to date myself.

TheLocehiliosan commented 2 years ago

Have you tried yadm add -u? That will add any files already tracked.

skwde commented 2 years ago

Yes it almost does what I want. However it is missing the 'track entire (sub)directory'.

How do I have entire subdirectories like e.g. ~/.vim/ tracked?

Lite5h4dow commented 2 years ago

you would track the folder with add ~/.vim/*

skwde commented 2 years ago

Hmm, this does not work. Try

yadm status # says nothing to commit
yadm add ~/.vim/*
touch ~/.vim/test.file
yadm status # says nothing to commit

Note, my whole point is to avoid having to add files in a folder which I want to have tracked (here ~/.vim/) manually whenever I add a new file to the folder in question.

Lite5h4dow commented 2 years ago

thing is git wont track a folder with nothing in it if there is nothing there there is nothing to track and track changes.

Lite5h4dow commented 2 years ago

also it wont track "folders". git only tracks files. they have to be there for git to track them but once you've made them you can track them like that

xenoterracide commented 2 years ago

huh, this wouldn't do quite what you want, and it doesn't actually work, but I'm not sure why, it just hangs

yadm gitconfig "alias.all" '!yadm add -u; yadm add'
yadm all ~/.foo 

to be honest though, I'm not entirely certain why that's not a git command already, might be worth asking git to add a -U --update-and-add-path for this, because it seems strange that you can't do that right now (that I can see, in porcelain)

nyanpasu64 commented 2 years ago

Hmm, this does not work. Try

yadm status # says nothing to commit
yadm add ~/.vim/*
touch ~/.vim/test.file
yadm status # says nothing to commit

Note, my whole point is to avoid having to add files in a folder which I want to have tracked (here ~/.vim/) manually whenever I add a new file to the folder in question.

thing is git wont track a folder with nothing in it if there is nothing there there is nothing to track and track changes.

In my case, I want to yadm add ~/.config/fish, then when I define new aliases in the directory, I want them to be picked up as untracked files (but new files in other directories are ignored). A standalone Git repository shows the following when I run git status:

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        asdf

But if I touch ~/.config/fish/asdf, then yadm status shows nothing to commit (use -u to show untracked files). And if I run yadm status -u, it hangs trying to list all files in my home directory.

Is there a way to opt specific directories into "show untracked files", so newly created files in ~/config/fish/ (or ~/.vim/) are shown inyadm status, but not newly created files in~/Downloads/`?

github-actions[bot] commented 2 years ago

This issue has been labeled as stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

nyanpasu64 commented 2 years ago

In my case, I added an alias/function yadm-add:

  yadm add -u
  yadm add ~/.config/fish
  yadm add ~/path

Nonetheless I still think "adding a folder to yadm" is an important missing feature (yadm add -u only updates existing files not folders, and yadm add -A adds your entire homedir).

github-actions[bot] commented 2 years ago

This issue has been labeled as stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

nyanpasu64 commented 2 years ago

This issue is still a concern.

github-actions[bot] commented 2 years ago

This issue has been labeled as stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

skwde commented 2 years ago

Still interested in this.

nyanpasu64 commented 2 years ago

poke

github-actions[bot] commented 2 years ago

This issue has been labeled as stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

nyanpasu64 commented 2 years ago

i don't care anymore. you win, stalebot.

github-actions[bot] commented 1 year ago

This issue has been labeled as stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 1 year ago

This issue was closed because it has been labeled as stale for 7 days with no activity.

Susensio commented 1 year ago

Maybe this could be achieved with submodules?

TheLocehiliosan commented 1 year ago

I strive to keep the interface of yadm inline with that of Git. This helps in two ways. First, yadm is a wrapper around Git, and any new features, updated interface, etc. simply join the party without any effort. Second, it allows users to intuitively understand what yadm will do. The more things that yadm does differently the more confusing it can be.

Those that would like yadm to be able to track directories (in a way that Git does not) can add an alias which adds those directories.