gh icon indicating copy to clipboard operation
gh copied to clipboard

Fix commands with iterative values

Open henvic opened this issue 10 years ago • 1 comments

i.e., gh pr --open --number 21 --number 1

Number is an interative value of the gh pull-request command.

The hook structure is broken and gh will crash because the afterHooksCallback callback is undefined on the second run.

henvic avatar Mar 04 '15 03:03 henvic

The problem is being caused because of a race condition between the hook functionality and the iterative values functionality.

The hooks are designed to be used once in a time and rely on some global state, such as the NODEGH_HOOK_IS_LOCKED environmental variable.

However, when you trigger gh pull-request --open --number x --number y the pull-request open command is executed twice (in parallel).

Killing the hooks functionality is out of question.

If we kill the parallelism, operations will have lower performance and the hooks will work again. The impact is that it'd be slower, given that most gh operations requires remote calls.

The best option I see is that we stop abusing global variables right away.

Mostly, we can just pass the needed parameters to the new process invoked on the hook creation (in case it's gh).

The following are all instances of global / environmental variables we currently use on GH:

  1. GH_VERBOSE (safe)
  2. GH_PATH (safe)
  3. GH_GIT_COMMAND (safe)
  4. NODEGH_PLUGIN (maybe unsafe)
  5. NODEGH_HOOK_IS_LOCKED (unsafe)

henvic avatar Mar 05 '15 13:03 henvic