diff options
author | Mike Frysinger <vapier@google.com> | 2019-06-18 17:23:39 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@google.com> | 2019-07-27 01:10:40 +0000 |
commit | f7c51606f0eae56f0cf52c54713f7816d8e9f97c (patch) | |
tree | 0ed377b68aa43d1440d738cb4fe176e08bca218d /docs/python-support.md | |
parent | 745be2ede1e67421275afc00c04d996d9d6908ee (diff) | |
download | git-repo-f7c51606f0eae56f0cf52c54713f7816d8e9f97c.tar.gz |
hooks: support external hooks running different Python version
As we convert repo to support Python 3, the version of Python that we
use might not be the version that repo hooks users have written for.
Since repo upgrades are not immediate, and not easily under direct
control of end users (relative to the projects maintaining the hook
code), allow hook authors to declare the version of Python that they
want to use.
Now repo will read the shebang from the hook script and compare it
against the version of Python repo itself is running under. If they
differ, we'll try to execute a separate instance of Python and have
it load & execute the hook. If things are compatible, then we still
use the inprocess execution logic that we have today.
This allows repo hook users to upgrade on their own schedule (they
could even upgrade to Python 3 ahead of us) without having to worry
about their supported version being exactly in sync with repo's.
Bug: https://crbug.com/gerrit/10418
Change-Id: I97c7c96b64fb2ee465c39b90e9bdcc76394a146a
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/228432
Reviewed-by: David Pursehouse <dpursehouse@collab.net>
Tested-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'docs/python-support.md')
-rw-r--r-- | docs/python-support.md | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/docs/python-support.md b/docs/python-support.md index af19cd05..35806de7 100644 --- a/docs/python-support.md +++ b/docs/python-support.md | |||
@@ -28,5 +28,20 @@ The master branch will require Python 3.6 at a minimum. | |||
28 | If the system has an older version of Python 3, then users will have to select | 28 | If the system has an older version of Python 3, then users will have to select |
29 | the legacy Python 2 branch instead. | 29 | the legacy Python 2 branch instead. |
30 | 30 | ||
31 | ### repo hooks | ||
31 | 32 | ||
33 | Projects that use [repo hooks] run on independent schedules. | ||
34 | They might migrate to Python 3 earlier or later than us. | ||
35 | To support them, we'll probe the shebang of the hook script and if we find an | ||
36 | interpreter in there that indicates a different version than repo is currently | ||
37 | running under, we'll attempt to reexec ourselves under that. | ||
38 | |||
39 | For example, a hook with a header like `#!/usr/bin/python2` will have repo | ||
40 | execute `/usr/bin/python2` to execute the hook code specifically if repo is | ||
41 | currently running Python 3. | ||
42 | |||
43 | For more details, consult the [repo hooks] documentation. | ||
44 | |||
45 | |||
46 | [repo hooks]: ./repo-hooks.md | ||
32 | [repo launcher]: ../repo | 47 | [repo launcher]: ../repo |