File: //kunden/lib/python3/dist-packages/dulwich/__pycache__/repo.cpython-39.pyc
a
3k�_!� � @ s� d Z ddlmZ ddlZddlZddlZddlZddlmZm Z m
Z
mZmZm
Z
mZ e
rtddlmZmZ ddlmZ ddlmZmZmZmZmZmZmZmZmZ ddlmZ dd l m!Z!m"Z"m#Z#m$Z$ dd
l%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z, ddl-m.Z. ddl/m0Z0m1Z1m2Z2m3Z3m4Z4 dd
l5m6Z6 ddl7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZA ddlBZBdZCdZDdZEdZFdZGdZHdZIdZJdZKdgeEgeEeFgeEeGgdgdggZLdZMG dd� deN�ZOe ePePf d�dd �ZQd:d!eeP eRd"�d#d$�ZSd%d&� ZTeeR eeReeR f d'�d(d)�ZUeeReeR f eRd'�d*d+�ZVd,d-� ZWG d.d/� d/eX�ZYG d0d1� d1eX�ZZd2d3� Z[G d4d5� d5eN�Z\G d6d7� d7eZ�Z]G d8d9� d9eZ�Z^dS );z�Repository access.
This module contains the base class for git repositories
(BaseRepo) and an implementation which uses a repository on
local disk (Repo).
� )�BytesION)�Optional�Tuple�
TYPE_CHECKING�List�Dict�Union�Iterable)�
StackedConfig�
ConfigFile��Index) �NoIndexPresent�NotBlobError�NotCommitError�NotGitRepository�NotTreeError�NotTagError�CommitError�RefFormatError� HookError)�GitFile)�DiskObjectStore�MemoryObjectStore�BaseObjectStore�ObjectStoreGraphWalker)�check_hexsha�valid_hexsha�Blob�Commit�ShaFile�Tag�Tree)�pack_objects_to_data)�Hook�PreCommitShellHook�PostCommitShellHook�CommitMsgShellHook�PostReceiveShellHook)�BlobNormalizer)
�ANNOTATED_TAG_SUFFIX�check_ref_format�
RefsContainer�DictRefsContainer�InfoRefsContainer�DiskRefsContainer�read_packed_refs�read_packed_refs_with_peeled�write_packed_refs�SYMREFz.git�objects�refsZtags�heads�index� commondirZgitdirZ worktreesZbranches�hooks�infos refs/heads/masterc @ s e Zd ZdZdd� ZdS )�InvalidUserIdentityz1User identity is not of the format 'user <email>'c C s
|| _ d S �N)�identity)�selfr= � r? �./usr/lib/python3/dist-packages/dulwich/repo.py�__init__� s zInvalidUserIdentity.__init__N��__name__�
__module__�__qualname__�__doc__rA r? r? r? r@ r; s r; ��returnc C s� dd l } dd l}| �� }zdd l}W n ty: d }Y n80 z|�|�j}W n tyb d }Y n0 |�d�d }|sz|}t j
�d�}|d u r�d�||�
� �}||fS )Nr �,ZEMAILz{}@{})�getpass�socketZgetuser�pwd�ImportError�getpwnamZpw_gecos�KeyError�split�os�environ�get�formatZgethostname)rJ rK ZusernamerL �fullnameZgecos�emailr? r? r@ �_get_default_identity� s$
rW r
��config�kindrH c C s d}d}|rXt j�d| d �}|dur2|�d�}t j�d| d �}|durX|�d�}|du r�z| �dd�}W n ty� d}Y n0 |du r�z| �dd�}W n ty� d}Y n0 t� \}}|du r�|�d�}|du r�|�d�}|�d ��r
|�d
��r
|dd� }|d
| d
S )aa Determine the identity to use for new commits.
If kind is set, this first checks
GIT_${KIND}_NAME and GIT_${KIND}_EMAIL.
If those variables are not set, then it will fall back
to reading the user.name and user.email settings from
the specified configuration.
If that also fails, then it will fall back to using
the current users' identity as obtained from the host
system (e.g. the gecos field, $EMAIL, $USER@$(hostname -f).
Args:
kind: Optional kind to return identity for,
usually either "AUTHOR" or "COMMITTER".
Returns:
A user identity
NZGIT_Z_NAME�utf-8Z_EMAIL)�user�namerV � <� >� ���� <)rQ rR rS �encoderO rW �
startswith�endswith)rY rZ r\ rV Zuser_ucZemail_ucZdefault_userZ
default_emailr? r? r@ �get_user_identity� s6
rf c C sD z| � dd�\}}W n ty. t| ��Y n0 d|vr@t| ��dS )z�Verify that a user identity is formatted correctly.
Args:
identity: User identity bytestring
Raises:
InvalidUserIdentity: Raised when identity is invalid
rb r` r_ N)rP �
ValueErrorr; )r= ZfstZsndr? r? r@ �check_user_identity� s rh )�graftpointsrH c C sf i }| D ]X}|� dd�}|d }t|�dkr:|d � � }ng }|g| D ]}t|d� qH|||<