-
Notifications
You must be signed in to change notification settings - Fork 13
git-aware and add-to-package functionality #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
modifies tests/overwrites:
new -r option allows target replacement, if the two files have equal
content (according to diff)
addition to tests/git:
a safely versioned file will be overwritten, if the user has
supplied the -g option
The first argument of list_files, list_dirs, list_git_files, and list_git_dirs, is now a path.
A new CLI option -a PACKAGE will take SOURCE command-line arguments, and add these to the destination specified by -a PACKAGE. PACKAGE is a path. The recommended way to use this towards a git repo is with the -g option. If the repo is clean the sources may overwrite the working tree and will also stage the new additions for review by the user.
Tests added to test the add to package option -a
The default behaviour while adding package sources is now to copy symlinks in directly e.g. with `cp -d`. This commit also adds an `-l` option to follow/resolve symlinks so only files are added.
macos 'cp' has a different default behavior for dereferencing symlinks I don't have access to macos, so this commit has not been tested
The option `-d` is short for `--dereference` which has been used in a similar way with cp.
This commit adds a function stowsh_list_status that lists the files in SRCs and displays the corresponding file at the target if given by the -t option or '.', otherwise. If the user supplies the -g option a column is added to display the SRC git status with characters as produced by the `git status --porcelain` command. This commit introduces a new dependency: `column` from the linux-util package. It could be removed, by simplifying the report format when it is not present. Not thoroughly tested.
This changes the behavior of the file listing the -g option so also untracked files will be installed/uninstalled. However I'm not 100% convinced it's a good idea.
When using the add `-a` command the `-c` option will allows the user to continue to add files to the current commit. The test of whether or not the path given with `-a` points into a repo is moved into a new function git_is_path_inside_repo(). Testing of whether a repo is clean is now done only once per call.
|
Very sorry about the delay in reviewing this. Looks very interesting! Will take a proper look asap. |
|
No worries! I didn't have time to test it for weeks. Now, I got to use it a little bit last week, and the underlying functionality appears nearly usable - however I don't quite like the design of options, as it seems a bit too cryptic how they should be used together at the moment. I think I would have preferred some sub-commands like 'add', 'install', 'uninstall', 'list' and the likes. Unfortunately I don't really know the original stow very well, so this might start to depart a little bit much from the original concept(s)? |
`-u` allows install uninstall with -g option to operate also on untracked files. Adding `-u` has a use as `-g` is now a more generic 'git-aware' option and not simply a filter to operate only on git-cached files. Also improved the 'git' test with colorized output. Check shfmt integration test.
|
I checked the integration tests. It seems I had broken the default filter-behavior of -g, so I added -u as an option to get untracked files back into the mix. Using -g and -u together gives the benefit of allowing both cached and untracked files to be installed/uninstalled but it excludes standard excluded files, such as those in .gitignore. This is nice to avoid installing ignored files such as *.swp files and so on, which would be the default behavior without -g. I also used shfmt this time. 👍🏼 |
Making this PR now as a placeholder for comments/review -- however it's not a requested PR and it does change a little bit much.
Most of the changed functionality in this PR is explained in the below text (copied from the top of README.md.
Additionally after that README an
-loption has been added to affect what to do with symlinks (add them as files or symlinks).I think the behavior and choice of letters may be thought through again as it has been ad-hoc. It could also be good to think ahead if these options are ever going to be changed to a --long-option style.
I will probably discover a few more things when I start to use this code (over the next couple of days).
The following is a repetition of the information added to the top of README.md :
A new
-a PACKAGE_DIRoption can be used to add files from a target into thepackage directory. The full expected use of the
-aoption is-a PACKAGE_DIR -t TARGET_DIR SOURCEFILES...,where
SOURCEFILES...are referenced from the current working directory inthe shell.
If the user supplies an
-rflag, then on installation of a package when a file inthe TARGET is encountered that is identical to the corresponding file in PACKAGE,
the PACKAGE version will be overwritten by the TARGET and the TARGET will be
convert to a symlink as it would when no file was encountered.
The
-goption will now test the git status of package files, and if therepo is clean
-gwill:For installations
-gwill overwrite safely revisioned package files withwhat was found in the target folder. The benefit of this is if you install
a package somewhere and you want to see what the changes were you can
afterwards use git diff tools in the package directory to check this,
and determine if you want to revert it or stage & commit some of the changes.
When adding packages with
-g -a PACKAGE_DIR -t TARGET_DIR SOURCEFILES...it willcopy and overwrite revisioned files in PACKAGE_DIR with what it found in
the SOURCES.
[Edits] : Added mention of the
-rflag. Note I still haven't had time to field test this ...