Refactor single try to update-reset repository into function

Change-Id: I99994c603739d0a288ee7497e2e9299cf62b5ad3