Last active
October 29, 2021 19:59
-
-
Save ZZromanZZ/22b38cbce3a84fd6e4e0 to your computer and use it in GitHub Desktop.
Composer install after change in GIT repository
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#-*- coding: utf-8 -*- | |
import subprocess | |
import string | |
import os | |
HOOK_DIR = os.path.dirname(os.path.realpath(__file__)) | |
ROOT_DIR = os.path.dirname(os.path.dirname(HOOK_DIR)) | |
def getChangeList(): | |
"""Retrieve the active Git change-list | |
""" | |
files = subprocess.Popen(['git', 'diff', '--name-status', 'master@{1}'], stdout=subprocess.PIPE) | |
results = files.stdout.read() | |
return results | |
def main(): | |
"""Update composer if `composer.lock` exists in the active change-list | |
""" | |
if getChangeList().find('composer.lock') > 0: | |
os.chdir(ROOT_DIR) | |
subprocess.Popen(['composer', 'install']) | |
if __name__ == '__main__': | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment