PK!dtgit_hooks_1c/__about__.py__version__ = '8.0.3' PK!ضgit_hooks_1c/__init__.py# -*- coding: utf-8 -*- import logging # noinspection PyUnresolvedReferences from git_hooks_1c.__about__ import __version__ # noinspection PyUnresolvedReferences logging.getLogger().setLevel(logging.DEBUG) logger = logging.getLogger(__name__) PK!git_hooks_1c/__main__.py# -*- coding: utf-8 -*- from pathlib import Path import sys from git_hooks_1c.core import run sys.path.insert(0, Path(__file__).parent.parent) if __name__ == '__main__': run() PK!m5git_hooks_1c/cli.py# -*- coding: utf-8 -*- from argparse import ArgumentParser from cjk_commons.logging_ import add_logging_arguments from git_hooks_1c import __version__, install, pre_commit, uninstall def get_argparser() -> ArgumentParser: parser = ArgumentParser( prog='gh1c', description='Git hooks utilities for 1C:Enterprise', add_help=False) parser.add_argument( '-h', '--help', action='help', help='Show this help message and exit' ) parser.add_argument( '-v', '--version', action='version', version='%(prog)s, ver. {0}'.format(__version__), help='Show version' ) add_logging_arguments(parser) subparsers = parser.add_subparsers(dest='subparser_name') install.add_subparser(subparsers) pre_commit.add_subparser(subparsers) uninstall.add_subparser(subparsers) return parser PK!KURRgit_hooks_1c/core.py# -*- coding: utf-8 -*- import sys from cjk_commons.logging_ import add_loggers from git_hooks_1c import logger as main_logger from git_hooks_1c.cli import get_argparser def run() -> None: argparser = get_argparser() args = argparser.parse_args(sys.argv[1:]) add_loggers(args, main_logger) args.func(args) PK! e11git_hooks_1c/install.py# -*- coding: utf-8 -*- import logging from pathlib import Path import subprocess import shutil logger = logging.getLogger(__name__) # noinspection PyUnusedLocal def run(args) -> None: try: script_dir_fullpath = Path(__file__).parent.absolute() current_dir_fullpath = Path('.git', 'hooks').absolute() pre_commit_file_fullpath = Path(script_dir_fullpath, 'pre-commit.sample') pre_commit_symbolic_fullpath = Path(current_dir_fullpath, 'pre-commit') if pre_commit_symbolic_fullpath.exists() and not args.force: print('git-hooks-1c already exist') else: shutil.copyfile(str(pre_commit_file_fullpath), str(pre_commit_symbolic_fullpath)) print('git-hooks-1c installed') args_au = [ 'cmd.exe', '/C', 'git', 'config', '--local', 'core.quotepath', 'false' ] subprocess.call(args_au) except Exception as e: logger.exception(e) def add_subparser(subparsers) -> None: decs = 'Install hooks' subparser = subparsers.add_parser( Path(__file__).stem, help=decs, description=decs, add_help=False ) subparser.set_defaults(func=run) subparser.add_argument( '-h', '--help', action='help', help='Show this help message and exit' ) subparser.add_argument( '-f', '--force', action='store_true', help='Install hooks anyway' ) PK!=OSSgit_hooks_1c/pre-commit.sample#!/bin/sh cmd //C "workon git-hooks-1c & cd- & gh1c.exe pre_commit & deactivate" PK!y / / git_hooks_1c/pre_commit.py# -*- coding: utf-8 -*- import logging from pathlib import Path import subprocess from typing import List import re import shutil from parse_1c_build import Parser logger = logging.getLogger(__name__) added_or_modified = re.compile(r'^\s*[AM]\s+"?(?P[^"]*)"?') def get_added_or_modified_file_fullpaths() -> List[Path]: result = [] try: args_au = [ 'git', 'status', '--porcelain' ] output = subprocess.check_output(args_au).decode('utf-8') except subprocess.CalledProcessError: return result for line in output.split('\n'): if line != '': match = added_or_modified.match(line) if match: added_or_modified_file_fullname = Path(match.group('rel_name')).absolute() if added_or_modified_file_fullname.name.lower() != 'readme.md': result.append(added_or_modified_file_fullname) return result def get_for_processing_file_fullpaths(file_fullpaths: List[Path]) -> List[Path]: result = [] for file_fullpath in file_fullpaths: if file_fullpath.suffix.lower() in ['.epf', '.erf', '.ert', '.md']: result.append(file_fullpath) return result def parse(file_fullpaths: List[Path]) -> List[Path]: result = [] parser = Parser() for file_fullpath in file_fullpaths: source_dir_fullpath = Path( file_fullpath.parent, file_fullpath.stem + '_' + file_fullpath.suffix[1:] + '_src') if not source_dir_fullpath.exists(): source_dir_fullpath.mkdir(parents=True) else: shutil.rmtree(source_dir_fullpath) parser.run(file_fullpath, source_dir_fullpath) result.append(source_dir_fullpath) return result def add_to_index(dir_fullpaths: List[Path]) -> None: for dir_fullpath in dir_fullpaths: args_au = [ 'git', 'add', '--all', str(dir_fullpath) ] exit_code = subprocess.check_call(args_au) if exit_code != 0: exit(exit_code) # noinspection PyUnusedLocal def run(args) -> None: try: added_or_modified_file_fullpaths = get_added_or_modified_file_fullpaths() for_processing_file_fullpaths = get_for_processing_file_fullpaths(added_or_modified_file_fullpaths) if len(for_processing_file_fullpaths) == 0: exit(0) for_indexing_source_dir_fullpaths = parse(for_processing_file_fullpaths) add_to_index(for_indexing_source_dir_fullpaths) except Exception as e: logger.exception(e) def add_subparser(subparsers) -> None: decs = 'Pre-commit for 1C:Enterprise files' subparser = subparsers.add_parser( Path(__file__).stem, help=decs, description=decs, add_help=False ) subparser.set_defaults(func=run) subparser.add_argument( '-h', '--help', action='help', help='Show this help message and exit' ) PK!Umgit_hooks_1c/uninstall.py# -*- coding: utf-8 -*- import logging from pathlib import Path logger = logging.getLogger(__name__) # noinspection PyUnusedLocal def run(args) -> None: try: current_dir_fullpath = Path('.git', 'hooks').absolute() pre_commit_symbolic_fullpath = Path(current_dir_fullpath, 'pre-commit') if pre_commit_symbolic_fullpath.exists(): pre_commit_symbolic_fullpath.unlink() print('git-hooks-1c uninstalled') else: print('git-hooks-1c not installed') except Exception as e: logger.exception(e) def add_subparser(subparsers) -> None: decs = 'Uninstall hooks' subparser = subparsers.add_parser( Path(__file__).stem, help=decs, description=decs, add_help=False ) subparser.set_defaults(func=run) subparser.add_argument( '-h', '--help', action='help', help='Show this help message and exit' ) PK!Hr42-git_hooks_1c-8.0.3.dist-info/entry_points.txtN+I/N.,()J0LM,.7L֋M̋**PK!HڽTU"git_hooks_1c-8.0.3.dist-info/WHEEL A н#Z;/"d&F[xzw@Zpy3Fv]\fi4WZ^EgM_-]#0(q7PK!Hȃ- %git_hooks_1c-8.0.3.dist-info/METADATAWNGSz[#@`N5̤7d ? JB.9#dxTWw–읙L&$B|6< ӎiV~ϽYiKy#_IE DqҘ 1f}uxm '^GdDJgaoXo-# f3vvqg8}{c!_.GKbrVfbǦV ⧂D0+(l&` 5y._dA/=x9a6^Gt(/myP9*e}K_Y2?M;ˑJ`68{M[g?T'G|ȭ BП%'H8*2qѡIclC( >KQ<.ek͜Dk=mNEζm#6>%Ҙحvw3fWP(6/Rm,b)0h^z"EȐF}- sFQE_|ʃ2-U(.3xQA8K ^QE.szEZ@ZVzG6J^"̵EoTeZrÑbϴ֍-eaRLfhؒ \U@i Y \'sSux,0aQȬ,2,+ C\vb4ea"h=dg_p~CekP1{va((4l9J>]7h#2G T(6eQ Ji%Xχk"Ǚu?+mMh7 y=؄Թ 8ֈqqgze)w [gZ2]:}"f_a;nvbX6S>Km]x(\cB (h+oJRz*_ 2iO7, |ƛNl33s+z?TQ~_OU,_PK!HW,il#git_hooks_1c-8.0.3.dist-info/RECORD}ɒ@}} $¢(( "@DHe΄kFVD}"0; a|{ᬙ(Ǭ0k`ZVƓZRm |=gbYJe>WU1{в&d{ C,ٶs y~(V߽2FՋbI6>1˗7^ҜRٴܬZjJ3\j簬t_%}C?ɜ?.tBv =Yr~g%S+WߛEc\7G yFf˜n*q_K7$_hq̸aBZJ+MQEBl.n{1R8>>չ@ 37؇猣"C*T!>De7IcˎwmoNeEm&16JەR]"1@?V'uW]ٮBQPK!dtgit_hooks_1c/__about__.pyPK!ضNgit_hooks_1c/__init__.pyPK!git_hooks_1c/__main__.pyPK!m5ygit_hooks_1c/cli.pyPK!KURR.git_hooks_1c/core.pyPK! e11git_hooks_1c/install.pyPK!=OSSgit_hooks_1c/pre-commit.samplePK!y / / git_hooks_1c/pre_commit.pyPK!Umgit_hooks_1c/uninstall.pyPK!Hr42-git_hooks_1c-8.0.3.dist-info/entry_points.txtPK!HڽTU"git_hooks_1c-8.0.3.dist-info/WHEELPK!Hȃ- %0 git_hooks_1c-8.0.3.dist-info/METADATAPK!HW,il#v%git_hooks_1c-8.0.3.dist-info/RECORDPK #(