---

###########################################################
#   0- Clone source repo
###########################################################

- name: "Checkout Archivematica code"
  git:
    repo: "https://github.com/artefactual/archivematica.git"
    dest: "{{ archivematica_src_dir }}/archivematica"
    version: "{{ archivematica_src_am_version }}"

- name: "Get Archivematica latest commit hash"
  command: "git rev-parse HEAD"
  args:
    chdir: "{{ archivematica_src_dir }}/archivematica"
  register: "latest_commit"

- name: "Save Archivematica last commit hash"
  shell: "echo {{ latest_commit.stdout }} > {{ archivematica_src_dir }}/archivematica-commit.txt"

# TODO: Make use of latest_commit

---

###########################################################
#   0- Clone source repo
###########################################################

- name: "Checkout Archivematica code"
  git:
    repo: "https://github.com/artefactual/archivematica.git"
    dest: "{{ archivematica_src_dir }}/archivematica"
    version: "{{ archivematica_src_am_version }}"
    force: "yes"

- name: "Get Archivematica latest commit hash"
  command: "git rev-parse HEAD"
  args:
    chdir: "{{ archivematica_src_dir }}/archivematica"
  register: "latest_commit"

- name: "Save Archivematica last commit hash"
  shell: "echo {{ latest_commit.stdout }} > {{ archivematica_src_dir }}/archivematica-commit.txt"

# TODO: Make use of latest_commit

Add force:yes to git task that pulls AM repos
Add force:yes to git task that pulls AM repos
