Decode a given string (bytes or otherwise) using configured path encoding options.
(path)
| 298 | |
| 299 | |
| 300 | def decode_path(path): |
| 301 | """Decode a given string (bytes or otherwise) using configured path |
| 302 | encoding options. |
| 303 | """ |
| 304 | |
| 305 | encoding = gitConfig('git-p4.pathEncoding') or 'utf_8' |
| 306 | if bytes is not str: |
| 307 | return path.decode(encoding, errors='replace') if isinstance(path, bytes) else path |
| 308 | else: |
| 309 | try: |
| 310 | path.decode('ascii') |
| 311 | except: |
| 312 | path = path.decode(encoding, errors='replace') |
| 313 | if verbose: |
| 314 | print('Path with non-ASCII characters detected. Used {} to decode: {}'.format(encoding, path)) |
| 315 | return path |
| 316 | |
| 317 | |
| 318 | def run_git_hook(cmd, param=[]): |
no test coverage detected