Yorkie git hooks always fail with "not found" - husky

I am using yorkie 2.0.0, and cannot run any custom shell scripts in my git hooks. My directory structure looks like this:
<project root>
|-- .githooks
| |-- commit-msg
|
|-- package.json
|-- .git
| |-- hooks
| | |-- <all the proper yorkie git hooks files>
| |
| |-- <other .git stuff>
|
|-- <lots of other irrelevant files>
And my package.json has this gitHooks section:
"gitHooks": {
"commit-msg": ".githooks/commit-msg $GIT_PARAMS"
}
The commit-msg file is definitely executable, this is the ls -l line:
-rwxr-xr-x 1 dan dan 400 Sep 14 08:51 commit-msg
When I create a commit, I get the following output:
> running commit-msg hook: .githooks/commit-msg $GIT_PARAMS
/bin/sh: 1: .githooks/commit-msg: not found
commit-msg hook failed (add --no-verify to bypass)
I have tried all kinds of different directory structures and it is never found. I have changed my gitHook script in package.json to things like ls .githooks and the file shows up then.
What is going on? Why can't yorkie find my file?
(I've tagged this with husky because yorkie is a fork of husky with fairly minimal changes and there is no yorkie tag. The issue here is probably not specific to yorkie)

Turns out the not found was a red herring. This was a line endings issue.
After I converted the line endings inside commit-msg to LF, everything worked. I added the following line to my .gitattributes so this wouldn't keep happening every time I checked out a branch:
.githooks/* text eol=lf

Related

Script to extract only the MaxMind GeoLite2 Country database from gzip containing multiple files

Recently MaxMind changed their download policy, and the old simple format is no longer available. The new file format looks like this: GeoLite2-Country_20191231.tar.gz, and inside we have a folder with the same name containing two additional files.
Although there is an option to delete the date parameter from the link, it seems that the downloaded file will still contain the date.
Now, the problem is to extract that GeoLite2-Country.mmdb from the gzip file having that variable name programmatically.
The unzip part existing in my old script was this:
gunzip -c "$1"GeoLite2-Country.mmdb.gz > "$1"GeoLite2-Country.mmdb
The question is how to modify the above part for the new situation. Or, maybe someone knows another way to solve the same problem. Thanks in advance.
The folder structure:
-+ Geolite2-Country_YYYYMMDD.tar.gz:
|-+ Geolite2-Country_YYYYMMDD
|- licence.txt
|- copyright.txt
|- Geolite2-Country.mmdb
What I need is Geolite2-Country.mmdb in the current folder of gzip file.
tar -tf /GeoLite2-City.tar.gz | grep mmdb | xargs tar -xf /GeoLite2-City.tar.gz --strip-components 1 -C /
Just fix source and destination paths

Exclude directory from loading

As I know, non-Python files (i.e. file.sublime-menu, file.sublime-keymap, etc.) can be located at ANY level inside package directory:
Will be loaded? (Yes/No)
Packages
|-- Foo Package
| |-- Old version
| | |-- foo.sublime-menu Y - it is the problem
| | |-- foo.sublime-keymap Y - it is the problem
| | |-- foo.py N
| |
| |-- foo.sublime-menu Y
| |-- foo.sublime-keymap Y
| |-- foo.py Y
I want to have Old version directory inside Foo Package, but the problem is that old menu and keymap files will be loaded. Is there a way to have some special file (call it package.exclude for example) with exclusion rules? Something like
exclude:
./Old version
Other than changing the extension of the file to not be one that Sublime recognizes and loads, there is no way to stop it from finding and loading resources short of removing the file entirely or adding the package that they're stored in into the ignored_packages setting.

How can I create a patch to delete a folder and create new folder using diff?

For example I have two directories say old and new. The directory old has a sub-directory abc and the directory new has a sub-directory cde.
I tried creating patch by using
diff -ru old/ new/ > file.patch
I got following output in file.patch:
Only in old/: abc
Only in new/: cde
and when I tried to patch the file I got following error:
patch: **** Only garbage was found in the patch input.
When I try to create patch by using:
diff -ruN old/ new/ > file.patch
I get empty file.patch.
Is there any way to create a patch that when patched to old would delete abc and create cde in old?
The makepatch script is useful for this. I use this for almost all source-patches, along with diffstat. There is also applypatch (completing the task), though I do not use it myself.
The GNU diff new-file "-N" option does (used to not...) work with the recursion option "-r". So you could use
diff -r -N old new
I just verified that it works for diff 3.0 (which by now is rather old).

Installing Patches in linux

I have a patch file that I want to install in linux. I know there is a patch command, And I tried to use it like this:
patch -i file --verbose
where file is the patch file. But it asks me for the file to be patched(to be changed):
Hmm... Looks like a unified diff to me...
can't find file to patch at input line 17
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|From 13fac179aa50556ba3c60790a9beb6ca9d0b1b8b Mon Sep 17 00:00:00 2001
|From: Andrey Vagin <avagin#openvz.org>
|Date: Fri, 28 Jan 2011 23:31:20 +0300
|Subject: [PATCH rh5] vdso: export vdso_sysctl_vsyscall
|
|Signed-off-by: Andrey Vagin <avagin#openvz.org>
|---
| arch/x86_64/vdso/vclock_gettime.c | 4 ++--
| arch/x86_64/vdso/vextern.h | 1 +
| include/asm-x86_64/vsyscall.h | 1 +
| 3 files changed, 4 insertions(+), 2 deletions(-)
|
|diff --git a/arch/x86_64/vdso/vclock_gettime.c b/arch/x86_64/vdso/vclock_gettime.c
|index 5e15d01..3e586bf 100644
|--- a/arch/x86_64/vdso/vclock_gettime.c
|+++ b/arch/x86_64/vdso/vclock_gettime.c
--------------------------
File to patch:
I don't know what file should be changed so I tried to get that from the patch file itself. But of course there is no directory arch/x86_64/vdso/
This is the full patch file. Any help on how to install it?
A patch file like this contains the differences between two versions of text files.
This one contains changes to these source files:
arch/x86_64/vdso/vclock_gettime.c | 4 ++--
arch/x86_64/vdso/vextern.h | 1 +
include/asm-x86_64/vsyscall.h | 1 +
You can't install it. You can use it to patch the source code (if you have it), compile it and install the results. But I don't think that is what you want.
If you want to install bugfixes use your package manager (I guess it's 'yum' for RedHat).
I'm not good with patch files, but it seems to be a patch file in the 'git format'.
The easiest way to apply such files would be to
1) git clone <path_to_kernel_sources>
2) git checkout 13fac179aa50556ba3c60790a9beb6ca9d0b1b8b
3) git apply <patch_file>
That should take care of automatically applying it for you.
I'm not entirely sure if the commit ID 13fac179aa50556ba3c60790a9beb6ca9d0b1b8b is the correct one. I just picked that up from the e-mail part of your post.
You probably need some more arguments to patch(1). In particular, try
patch -p1 --verbose -i file

How do I get the effect of GNU tar's --strip-components with git-archive?

In broad terms, what I'd like is a direct tar-to-tar transformation where the result's root contains only a particular directory-subtree of the original.
To illustrate with an example, say I want only the gitweb directory from git's repository. Running
$ git archive --prefix=git-gitweb/ master gitweb | tar tf -
gives
git-gitweb/
git-gitweb/gitweb/
git-gitweb/gitweb/INSTALL
git-gitweb/gitweb/Makefile
git-gitweb/gitweb/README
git-gitweb/gitweb/gitweb.perl
git-gitweb/gitweb/static/
git-gitweb/gitweb/static/git-favicon.png
git-gitweb/gitweb/static/git-logo.png
git-gitweb/gitweb/static/gitweb.css
git-gitweb/gitweb/static/gitweb.js
but I want
git-gitweb/
git-gitweb/INSTALL
git-gitweb/Makefile
git-gitweb/...
The manual provides for extra backend-specific options, but attempting to pass --strip-components produces an error:
$ git archive --prefix=git-gitweb/ --strip-components=1 master gitweb | \
tar tf -
error: unknown option `strip-components=1'
usage: git archive [options] [...] ...
The tar backend isn't GNU tar anyway.
Someone in freenode's #gnu channel suggested Tardy, but it doesn't understand the output of git-archive:
$ git archive master > old.tar
$ tardy old.tar new.tar
tardy: old.tar: file type ``g'' unknown
Yes, I could extract the output of git-archive with --strip-components and create a new archive of the result, but I'm trying to avoid using the filesystem as a temporary variable.
Archive that directory as the CWD and you won't have the extra path component:
(cd gitweb; git archive --prefix=git-gitweb/ master .) | tar tf -
Or use this syntax as suggested by the git-archive man page:
git archive --prefix=git-gitweb/ master:gitweb | tar tf -

Resources