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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Fix access mode of prepare-commit-msg #17

Merged
merged 1 commit into from
Nov 26, 2016

Conversation

grdryn
Copy link
Contributor

@grdryn grdryn commented Nov 26, 2016

It seems that with fs.writeFile, the mode option needs to be specified as an octal number. I determined this after running gitmoji -i, and having the file created with very strange permissions:

$ stat .git/hooks/prepare-commit-msg
  File: '.git/hooks/prepare-commit-msg'
  Size: 70        	Blocks: 8          IO Block: 4096   regular file
Device: fd03h/64771d	Inode: 19398811    Links: 1
Access: (1361/--wxrw---t)  Uid: ( 1000/  grdryn)   Gid: ( 1000/  grdryn)
Context: unconfined_u:object_r:container_file_t:s0
Access: 2016-11-26 02:19:14.661093296 +0000
Modify: 2016-11-26 02:19:14.661093296 +0000
Change: 2016-11-26 02:19:14.661093296 +0000
 Birth: -

The docs[1] for this function give the default example as being in octal, and when I changed it and tried it out, it worked much better.

In addition, the rest of the files in .git/hooks/ appear to have mode 775 rather than 755, so I changed this here to match that also.

[1] https://nodejs.org/dist/latest-v7.x/docs/api/fs.html#fs_fs_writefile_file_data_options_callback

It seems that with fs.writeFile, the mode option needs to be specified
as an octal number. I determined this after running `gitmoji -i`, and
having the file created with very strange permissions:

```
$ stat .git/hooks/prepare-commit-msg
  File: '.git/hooks/prepare-commit-msg'
  Size: 70        	Blocks: 8          IO Block: 4096   regular file
Device: fd03h/64771d	Inode: 19398811    Links: 1
Access: (1361/--wxrw---t)  Uid: ( 1000/  grdryn)   Gid: ( 1000/  grdryn)
Context: unconfined_u:object_r:container_file_t:s0
Access: 2016-11-26 02:19:14.661093296 +0000
Modify: 2016-11-26 02:19:14.661093296 +0000
Change: 2016-11-26 02:19:14.661093296 +0000
 Birth: -
```

The docs[1] for this function give the default example as being in
octal, and when I changed it and tried it out, it worked much better.

In addition, the rest of the files in `.git/hooks/` appear to have
mode `775` rather than `755`, so I changed this here to match that
also.

[1] https://nodejs.org/dist/latest-v7.x/docs/api/fs.html#fs_fs_writefile_file_data_options_callback
@grdryn grdryn changed the title 馃悰 Fix access mode of prepare-commit-msg 馃悰 Fix access mode of prepare-commit-msg Nov 26, 2016
@carloscuesta
Copy link
Owner

Cool thanks for that @grdryn!

@carloscuesta carloscuesta merged commit 65ac7a8 into carloscuesta:master Nov 26, 2016
@QoVoQ QoVoQ mentioned this pull request Jun 18, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants