---
- name: Acquiring home of current user
  when: ansible_facts["system"] == "Linux"
  ansible.builtin.shell:
    cmd: "echo ~{{ ansible_user }}"
  register: ansible_user_home
- name: Acquiring current user
  when: ansible_facts["system"] == "Linux"
  ansible.builtin.shell:
    cmd: "echo {{ ansible_user }}"
- name: Configuring system-level git settings
  become: true
  block:
    - name: Making commit feedback more verbose
      community.general.git_config:
        name: commit.verbose
        scope: system
        value: "true"
        state: present
    - name: Setting default merge conflict approach algorithm
      community.general.git_config:
        name: merge.conflictstyle
        scope: system
        value: zdiff3
        state: present
    - name: Setting default merging tool for conflicts
      community.general.git_config:
        name: merge.tool
        scope: system
        value: nvimdiff
        state: present
    - name: Ensuring backups prior to merge solution implementation
      community.general.git_config:
        name: merge.keebbackup
        scope: system
        value: "true"
        state: present
    - name: Configuring rebase to autosquash
      community.general.git_config:
        name: rebase.autosquash
        scope: system
        value: "true"
        state: present
    - name: Enforcng error message for missing entries in local commit history
      community.general.git_config:
        name: rebase.missingCommitsCheck
        scope: system
        value: error
        state: present
    - name: Setting the default branch's default name on repository initialization
      community.general.git_config:
        name: init.defaultBranch
        scope: system
        value: main
        state: present
    - name: Setting default pager for, or called by, git
      community.general.git_config:
        name: core.pager
        scope: system
        value: delta
        state: present
    - name: Ensuring git push/pull space handling compatibility with non-Linux operating systems
      community.general.git_config:
        name: core.autocrlf
        scope: system
        value: "false"
        state: present
    - name: Setting default text editor for, or called by, git
      community.general.git_config:
        name: core.editor
        scope: system
        value: nvim
        state: present
    - name: Setting difference filtering tool to delta
      community.general.git_config:
        name: interactive.diffFilter
        scope: system
        value: delta
        state: present
    - name: Setting default  difference- finding or presenting approach algorithm
      community.general.git_config:
        name: diff.algorithm
        scope: system
        value: histogram
        state: present
    - name: Setting difference tool for, or called by, git
      community.general.git_config:
        name: diff.tool
        scope: system
        value: nvimdiffs
        state: present
    - name: Setting the default amount of context for git to show around a difference
      community.general.git_config:
        name: diff.context
        scope: system
        value: "10"
        state: present
    - name: Ensuring data integrity and validity is checked prior to fetch or transfer actions
      community.general.git_config:
        name: "{{ item }}.fsckobjects"
        scope: system
        value: "true"
        state: present
      loop:
        - transfer
        - fetch
    - name: Ensuring data integrity and validity is checked prior to reception of data
      community.general.git_config:
        name: receive.fsckObjects
        scope: system
        value: "true"
        state: present
    - name: Setting git TUI to have color
      community.general.git_config:
        name: color.ui
        scope: system
        value: "true"
        state: present
