---
- name: Acquiring home of current user
  when: ansible_facts["system"] == "Linux"
  ansible.builtin.shell:
    cmd: "echo ~{{ ansible_user }}"
  register: ansible_user_home
- name: Acquiring home of current user
  when: ansible_facts["system"] == "Linux"
  ansible.builtin.shell:
    cmd: "echo {{ ansible_user }}"
  register: current_user
- name: Moving git repository from initial path
  block:
    - name: Recursively copying directory and its contents to elsewhere
      ansible.builtin.copy:
        src: "{{ ansible_user_home.stdout }}/repos/.foreign/{{ source_code.repos.cli.name }}"
        remote_src: true
        dest: "{{ ansible_user_home.stdout }}/repos/"
        owner: "{{ ansible_user }}"
        group: "{{ ansible_user }}"
      register: new_compose_path
    - name: Deleting directory at previous path
      ansible.builtin.file:
        path: "{{ ansible_user_home.stdout }}/repos/.foreign/{{ source_code.repos.cli.name }}"
        state: absent
    - name: Creating directory for new bare repository
      ansible.builtin.file:
        path: "{{ ansible_user_home.stdout }}/src"
        recurse: true
        owner: "{{ ansible_user }}"
        group: "{{ ansible_user }}"
        state: directory
    - name: Creating bare repository
      ansible.builtin.command:
        cmd: "git init --bare {{ source_code.repos.cli.name }}.git"
        chdir: "{{ ansible_user_home.stdout }}/src"
        creates: "{{ ansible_user_home.stdout }}/src/{{ source_code.repos.cli.name }}.git"
- name: Running CLI utility
  when: source_code.repos.cli.run
  # become: true
  # become_user: "{{ current_user.stdout }}"
  block:
    - name: Warning about lack of implementation
      ansible.builtin.debug:
        msg: Not yet implemented