Commit 24a6ba51 authored by Lorenz Steinert's avatar Lorenz Steinert

post-merge hook wurde an neue ordnerstruktur angepasst

parent 03ee269e
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""check if proto.ini changed in commit and replace with the new on"""
import os
import sys
import shutil
import configparser
import subprocess
files = subprocess.check_output(['git', 'diff', '--name-only', 'HEAD@{1}', 'HEAD']).decode('utf-8').split('\n')
FILES = subprocess.check_output(['git', 'diff', '--name-only', 'HEAD@{1}',
'HEAD']).decode('utf-8').split('\n')
if 'proto.ini' not in os.listdir('.'):
shutil.copyfile('./proto.ini.default', './proto.ini')
raise SystemExit(0)
if 'proto.ini' not in os.listdir('./etc/'):
shutil.copyfile('./etc/proto.ini.default', './etc/proto.ini')
sys.exit(0)
config = configparser.ConfigParser()
config.read('./proto.ini')
config_default = configparser.ConfigParser()
config_default.read('./proto.ini.default')
CONFIG = configparser.ConfigParser()
CONFIG.read('./etc/proto.ini')
CONFIG_DEFAULT = configparser.ConfigParser()
CONFIG_DEFAULT.read('./etc/proto.ini.default')
if 'proto.ini.default' in files:
for i in config_default:
for j in config_default[i]:
if 'proto.ini.default' in FILES:
for i in CONFIG_DEFAULT:
for j in CONFIG_DEFAULT[i]:
try:
if j not in config[i]:
shutil.copyfile('./proto.ini', './proto.ini.bak')
shutil.copyfile('./proto.ini.default', './proto.ini')
raise SystemExit(0)
if j not in CONFIG[i]:
shutil.copyfile('./etc/proto.ini', './etc/proto.ini.bak')
shutil.copyfile('./etc/proto.ini.default', './etc/proto.ini')
sys.exit(0)
except:
shutil.copyfile('./proto.ini', './proto.ini.bak')
shutil.copyfile('./proto.ini.default', './proto.ini')
raise SystemExit(0)
shutil.copyfile('./etc/proto.ini', './etc/proto.ini.bak')
shutil.copyfile('./etc/proto.ini.default', './etc/proto.ini')
sys.exit(0)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment