Skip to content

Conversation

@hberge
Copy link

@hberge hberge commented Aug 2, 2022

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 -l option 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 :

  1. A new -a PACKAGE_DIR option can be used to add files from a target into the
    package directory. The full expected use of the -a option is
    -a PACKAGE_DIR -t TARGET_DIR SOURCEFILES...,
    where SOURCEFILES... are referenced from the current working directory in
    the shell.

  2. If the user supplies an -r flag, then on installation of a package when a file in
    the 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.

  3. The -g option will now test the git status of package files, and if the
    repo is clean -g will:

    • For installations -g will overwrite safely revisioned package files with
      what 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 will
      copy and overwrite revisioned files in PACKAGE_DIR with what it found in
      the SOURCES.

[Edits] : Added mention of the -r flag. Note I still haven't had time to field test this ...

hberge and others added 10 commits August 2, 2022 18:18
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.
hberge and others added 4 commits August 31, 2022 21:45
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.
@mikepqr
Copy link
Owner

mikepqr commented Sep 6, 2022

Very sorry about the delay in reviewing this. Looks very interesting! Will take a proper look asap.

@hberge
Copy link
Author

hberge commented Sep 6, 2022

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.
@hberge
Copy link
Author

hberge commented Sep 6, 2022

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. 👍🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants