Skip to content

Resolve post-checkout hook issue with pot generation

Doug Stull requested to merge resolve-post-checkout-hook-for-pot-file-gen into master

What does this MR do?

Problem

When developing locally and overcommit is activated, we encounter the below issue short-circuiting the finishing of the task when running bin/rake gettext:regenerate

09:29 $  bin/rake gettext:regenerate
touch /Users/dstull/projects/gdk/gitlab/locale/fa_IR/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/pa_IN/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/kab/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/fi_FI/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/ka_GE/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/ur_PK/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/sk_SK/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/ba_RU/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/ky_KG/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/fil_PH/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/zh_HK/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/bn_BD/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/am_ET/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/sr_SP/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/sv_SE/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/gl_ES/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/sw_KE/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/az_AZ/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/id_ID/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/pt_BR/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/ja/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/ig_NG/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/bn_IN/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/it/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/zh_TW/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/nb_NO/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/pt_PT/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/ru/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/hr_HR/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/cs_CZ/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/he_IL/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/as_IN/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/hi_IN/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/sl_SI/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/ro_RO/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/sr_CS/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/zh_CN/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/uz_UZ/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/nl_NL/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/bs_BA/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/hu_HU/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/uk/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/ar_SA/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/si_LK/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/et_EE/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/bg/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/de/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/ca_ES/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/ko/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/is_IS/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/mn_MN/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/ku_TR/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/eo/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/fr/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/es/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/en/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/cy_GB/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/el_GR/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/vi_VN/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/da_DK/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/pl_PL/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/lt_LT/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/tr_TR/gitlab.po.time_stamp
touch /Users/dstull/projects/gdk/gitlab/locale/sq_AL/gitlab.po.time_stamp
You have specified the `gemfile` option in your Overcommit configuration but have not added the `overcommit` gem to tooling/overcommit/Gemfile.
rake aborted!
failed to cleanup generated locale/*/gitlab.po files
/Users/dstull/projects/gdk/gitlab/lib/tasks/gettext.rake:42:in `block (2 levels) in <main>'
Tasks: TOP => gettext:regenerate
(See full trace by running task with --trace)

I believe this is due to the PostCheckout hook specifically.

Solution

Disable running of hooks for this targeted/specific command.

Other solutions like the one mentioned here to skip on file checkout doesn't seem to resolve the issue since it still instantiates overcommit. We need to disable that altogether.

making the command OVERCOMMIT_DISABLE=1 git checkout -- locale/*/gitlab.po doesn't work either in this case

I don't like solving this so bluntly, but in this case, it may be ok as it is a very targeted approach.

I have been solving this locally before this change with this command OVERCOMMIT_DISABLE=1 bin/rake gettext:regenerate, but I thought it would be good to fix for others if using overcommit as the command line fix is a local to user action they would have to take.

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Doug Stull

Merge request reports