Commit Graph

11 Commits

Author SHA1 Message Date
Daniel Lockyer
61b4a6828d Removed pre-push hook
- we no longer allow pushing to the `main` branch, so this hook is never
  used
- if you tried to push locally, it'd fail because I've since removed
  Lerna
- this commit cleans up the hook
2023-07-17 17:10:58 +02:00
Daniel Lockyer
ec9181921b
Fixed preventing git submodules from being committed
- because we now ignore git submodule changes, they didn't show up in
  `git diff --cached...`, so it was possible to get submodules to be
  committed
- you can re-enable submodules to be shown with `--ignore-submodules=none`
- this implements that
- we never want to allow submodules to be committed, so I've removed the
  prompt for faster feedback
2023-03-28 12:16:46 +02:00
Daniel Lockyer
846a9cdafc
Fixed pre-push hook running when pushing to fork
- this prevents the unit tests running if you're pushing to a fork,
  which we don't care about because it doesn't block the upstream `main`
2023-03-23 17:31:06 +01:00
Daniel Lockyer
56b407f1f4
Added pre-push hook to run unit tests on changed packages
fixes https://github.com/TryGhost/Toolbox/issues/532

- we should protect against failures entering `main` which could be
  avoided by running a quick unit test beforehand
- this reintroduces Lerna as it supports parallelisation and `--since`,
  to run linting and unit tests on packages that have changed since
  upstream
2023-03-23 11:27:43 +01:00
Daniel Lockyer
077ff89960
Removed pre-commit linting on non-main branches
- our use-case for this is to ensure that people don't push to
  `main` without running linting, as this can block CI from passing
  until the linting issue is resolved
- however, it can become annoying to run linting on non-main branches,
  especially when you just want to WIP some changes without caring for
  linting
- generally speaking, anyone who creates commits on a non-main branch is
  going to open them as a PR, so linting is run anyway
- this commit get the branch name and only runs linting if we're on
  `main`
2022-10-27 11:47:10 +07:00
Daniel Lockyer
e11636b6f8
Fixed execution path for lint commands in lint-staged
refs https://ghost.slack.com/archives/C02G9E68C/p1665497363885949

- we've seen an issue with `lint-staged` in the Admin package because it
  doesn't pick up the lint-todo file, so it incorrectly flags linting
  issues that we're ignoring
- this is happening because it runs the command from cwd, where the lint
  exclusion file does not exist
- thankfully, `lint-staged` has `--relative` which will run the command
  from the directory where the command is defined in config, so `ghost/admin`
  in our case, and that means the lint file is present and picked up
2022-10-11 21:54:58 +07:00
Daniel Lockyer
a37b2cd24e Switched to Husky + lint-staged for git hooks
- up until this commit, git hooks were only used by a handful of people
  because they were a pain:
  - they'd only be set up when you did `yarn setup`
  - the existing hooks ran `yarn lint` on all projects, which was
    incredibly slow
- as a result, not many of us actually had them enabled, but this would
  cause issues in CI because people were pushing un-linted commits
- other JS projects tend to use husky to automate the git hook setup and
  lint-staged to speed up linting on changed files
- this commit switches to using them both
  - `lint-staged` only runs `eslint` on staged JS files that are about to
    be committed - if there's a linting error, it will stop the commit
  - I've configured the pre-commit hook to successfully exit in CI because we
    don't want to run pre-commit hooks right now
- this means we can remove Grunt - yay!
2022-10-10 15:10:48 +07:00
Naz
bc464f8930 Fixed file permissions on pre-push hook
refs 002cf5b0eb

- The hook file has to be executable to be triggered in the pre-push stage:

hint: The '.git/hooks/pre-push' hook was ignored because it's not set as executable.
2022-05-05 22:09:44 +08:00
Naz
002cf5b0eb Moved linting check to pre-push git hook
refs 81cd5fac7e

- While developing locally it's common to commit small WIP changes which might contain linting errors. Having the check done once on a pre-push phase gives enoght protection from pushing out broken code and reduces frustration when developing locally
2022-05-05 21:36:56 +08:00
Naz
81cd5fac7e Added linting check to a pre-commit hook
refs 648530009d

- Naz has broken the main too many times - it's time to stop the atrocities.
- Having a lint check as a pre-commit hook will make it really hard commiting code with linting errors
2022-05-05 21:21:48 +08:00
Hannah Wolfe
e9a537004b Added pre-commit hook to handle submodules (#8302)
refs #8235

Usage:
- for existing development setups: `grunt symlink` (will create the pre-commit symlink)
- for fresh development setups: `npm run init` (symlinking happens as part of the typical set up)

-  Added pre-commit hook to handle submodules
  - Checks to see if there are any submodules about to be committed
  - Output matches closely to `git st` to make it easy to read
  - Requires interaction from the committer to accept that this really should be committed
-  Use grunt symlink to register githooks
  - Grunt symlink will make a link to the pre-commit hook
  - It ONLY does this if there isn't already a pre-commit hook, so won't overwrite anything
  - It does this as part of npm run init, not grunt init, because a release repo would NEVER want this
  - This is a dev tool, that configures the repo for development
2017-04-13 08:26:48 +01:00