Skip to content
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

Add skip to native git-lfs install #346

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Helcostr
Copy link

@Helcostr Helcostr commented Jul 27, 2024

Summary

  • Skips native git-lfs install if hooks contain git lfs hooks
  • Provide the config option auto-gitlfs-install

Details

Forcing default git-lfs hooks during preflight causes issues with custom hooks.

[04:11:29] [pool-4-thread-2/ERROR]: [STDERR] Hook already exists: pre-push
[04:11:29] [pool-4-thread-2/ERROR]: [STDERR] #!/bin/sh
[04:11:29] [pool-4-thread-2/ERROR]: [STDERR] command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'pre-push' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks').\n"; exit 2; }
[04:11:29] [pool-4-thread-2/ERROR]: [STDERR] git lfs pre-push "$@"
[04:11:29] [pool-4-thread-2/ERROR]: [STDERR] To resolve this, either:
[04:11:29] [pool-4-thread-2/ERROR]: [STDERR] 1: run `git lfs update --manual` for instructions on how to merge hooks.
[04:11:29] [pool-4-thread-2/ERROR]: [STDERR] 2: run `git lfs update --force` to overwrite your hook.

By checking for default git-lfs hooks in the contents of the files, we can skip a bad git-lfs attempted override.

The following three states will happen:

  • No Git-LFS hooks
    • Installs 4 fresh Git-LFS hooks no issue
  • Hooks that don't contain one or more Git-LFS hooks
    • Fails as Git-LFS install fails (we assume the user is advance, and needs to merge their own hooks)
    • TODO: add custom message to identify such an issue?
  • Has Git-LFS hooks
    • Continues with backup, even though the install would have potentially failed.

In addition, allows advance users to ignore a forced git-lfs assurance via the auto-gitlfs-install config (set to false will disable it).

Bug Fixes

Allows for the ignoring of bad git-lfs re-install even though the hooks are still git-lfs functional.

- Read the PrePushHook info from the JGit library.
- Looking for any form of `git lfs post-merge`
- PreflightUtils: add a hook checker b4 the git-install
 - This allows the git-install to ignore replacing custom hooks if the custom hook satisfy the git lfs hooks
- CommitUtils add info to syslog-info (for easier logs)
- nativeGitLfsUpdater
- nativeGitLfsHookCheck
@Helcostr
Copy link
Author

Helcostr commented Jul 27, 2024

We can hold off on squash-merging this pull request waiting for two things:

  1. setting up the i18n for a message talking about git hooks need to be manually replaced.
  2. adding a command to force git lfs init (where we then run the command git lfs install --local --force)

I am not sure of the direction to go in.

@pcal43
Copy link
Owner

pcal43 commented Jul 27, 2024

Thanks for this. I'd probably be more inclined to have a simple configuration switch that disables the installation behavior entirely. Just easier to maintain and less likely to complicate matters for advanced users.

I'll have to take a closer look in a few days, though.

@Helcostr
Copy link
Author

So we have this switch on by default? I am down to do so!

@pcal43
Copy link
Owner

pcal43 commented Jul 27, 2024

So we have this switch on by default? I am down to do so!

Mmm. I think it should be off by default, TBH. It's very much an 'advanced users' kind of thing. The vast majority of users don't even know what a git hook is.

But since it will be a git config option (like everything else in the mod), you can easily make it the default for yourself by setting it in your global git config.

@Helcostr
Copy link
Author

Helcostr commented Jul 27, 2024 via email

@pcal43
Copy link
Owner

pcal43 commented Jul 27, 2024

but the git hook is part of gitlfs install. that's why this needs to be on by default.

Yes, I'm aware. I think maybe I misunderstood what you're trying to achieve.

I thought you wanted the option of disabling the automatic 'lfs install' so that you could manage your own git hooks manually.

@Helcostr
Copy link
Author

Oh... switch that disables gitlfs while in the true position haha.

yeah my mistake. I meant to have a positive switch for gitlfs set to default on. but i think we are on the same page, just need to figure out what users will want to see " Disable auto GitLfS" switch or a switch for "auto gitlfs"

@Helcostr Helcostr marked this pull request as draft July 28, 2024 01:19
- I am coding mobile and can't test code
- Add en_us L10N for "auto-gitlfs-install"
- Tweak Preflight to launch gitlfs install on config true
- Add config enum AUTO_GITLFS_INSTALL
@Helcostr Helcostr marked this pull request as ready for review July 28, 2024 06:21
@Helcostr
Copy link
Author

@pcal43 is the i18n system for the following keys implemented at all?

  "fastback.help.command.set-autoback-action"    : "Set an action to perform during auto-backups.",
  "fastback.help.command.set-autoback-wait"      : "Set the minimum number of minutes to wait between auto-backups.",
  "fastback.help.command.set-remote"             : "Set the url for remote backups.",
  "fastback.help.command.set-remote-retention"   : "Set snapshot retention policy for the remote backup.",
  "fastback.help.command.set-retention"          : "Set snapshot retention policy.",
  "fastback.help.command.set-shutdown-action"    : "Set an action to perform on shutdown.",

@pcal43
Copy link
Owner

pcal43 commented Jul 28, 2024

They should be used for /backup help set xxx but it looks like I broke them a while back when I separated out the set subcommands.

@pcal43
Copy link
Owner

pcal43 commented Jul 28, 2024

...regarding the larger change, I appreciate the effort but I think it's a lot heavier than I would want it to be for a little-used flag. I don't think it needs a command; it would be just a simple config switch.

I'll add it myself next time I'm working on the mod.

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