(self, file_path)
| 26 | pass |
| 27 | |
| 28 | def __exclude_file(self, file_path): |
| 29 | dir_number = file_path.split('/') |
| 30 | ignore_path = file_path |
| 31 | |
| 32 | # gets the file path depth. |
| 33 | for i in dir_number: |
| 34 | # current directory. |
| 35 | dir_name = os.path.dirname(ignore_path) |
| 36 | ignore_path = dir_name |
| 37 | # judge the ignore file exists in the current directory. |
| 38 | ignore_file_path = os.path.join(dir_name, ".ignore_format.yml") |
| 39 | if not os.path.exists(ignore_file_path): |
| 40 | continue |
| 41 | try: |
| 42 | with open(ignore_file_path) as f: |
| 43 | ignore_config = yaml.safe_load(f.read()) |
| 44 | file_ignore = ignore_config.get("file_path", []) |
| 45 | dir_ignore = ignore_config.get("dir_path", []) |
| 46 | except Exception as e: |
| 47 | logging.error(e) |
| 48 | continue |
| 49 | logging.debug("ignore file path: {}".format(ignore_file_path)) |
| 50 | logging.debug("file_ignore: {}".format(file_ignore)) |
| 51 | logging.debug("dir_ignore: {}".format(dir_ignore)) |
| 52 | try: |
| 53 | # judge file_path in the ignore file. |
| 54 | for file in file_ignore: |
| 55 | if file is not None: |
| 56 | file_real_path = os.path.join(dir_name, file) |
| 57 | if file_real_path == file_path: |
| 58 | logging.info("ignore file path: {}".format(file_real_path)) |
| 59 | return 0 |
| 60 | |
| 61 | file_dir_path = os.path.dirname(file_path) |
| 62 | for _dir in dir_ignore: |
| 63 | if _dir is not None: |
| 64 | dir_real_path = os.path.join(dir_name, _dir) |
| 65 | if file_dir_path.startswith(dir_real_path): |
| 66 | logging.info("ignore dir path: {}".format(dir_real_path)) |
| 67 | return 0 |
| 68 | except Exception as e: |
| 69 | logging.error(e) |
| 70 | continue |
| 71 | |
| 72 | return 1 |
| 73 | |
| 74 | def get_new_file(self): |
| 75 | result = subprocess.run(['git', 'diff', '--name-only', 'HEAD', 'origin/master', '--diff-filter=ACMR', '--no-renames', '--full-index'], stdout = subprocess.PIPE) |
no test coverage detected