---
- name: git | Create config directory
  file:
    path: '{{ xdg_dir.config_home }}/git/templates/hooks'
    state: directory
    mode: '755'

- name: git | Copy config
  template:
    src: git/config.j2
    dest: '{{ xdg_dir.config_home }}/git/config'
    mode: '644'

- name: git | Install git-privacy with pip
  pip:
    name: gitprivacy
    virtualenv: '{{ xdg_dir.config_home }}/git/venv'
    state: latest

- name: git | Symlink git-privacy executable
  file:
    src: '{{ xdg_dir.config_home }}/git/venv/bin/git-privacy'
    dest: '{{ xdg_dir.bin_home }}/git-privacy'
    state: link

- name: git | Install git-privacy hooks globally
  copy:
    src: git/{{ item }}
    dest: '{{ xdg_dir.config_home }}/git/templates/hooks/{{ item }}'
    mode: '755'
  loop:
    - post-commit
    - post-rewrite
    - pre-commit
    - pre-push
