Commits all local changes (if any) into a working branch,
        merges it with 'master'.

        Checks out your old branch afterwards.

        |appteardown| if conflicts are discovered

def cleanup(self):
        '''
        Commits all local changes (if any) into a working branch,
        merges it with 'master'.

        Checks out your old branch afterwards.

        |appteardown| if conflicts are discovered
        '''

        hostname = get_hostname()
        old_branch = self.branch

        changes = self.status
        if not changes.get('clean'):

            self.branch = hostname
            utmo = changes.get('untracked', []) + changes.get('modified', [])

            for f in utmo:
                self.m(
                    'adding file to repository',
                    cmdd=(dict(cmd='git add %s' % (f), cwd=self.local)),
                    more=f,
                    critical=False
                )
            for f in changes.get('deleted', []):
                self.m(
                    'deleting file from repository',
                    cmdd=(dict(cmd='git rm %s' % (f), cwd=self.local)),
                    more=f,
                    critical=False
                )
            if changes.get('conflicting'):
                self.m(
                    'Well done! You have conflicting files in the repository!',
                    state=True,
                    more=changes
                )

            self.m(
                'auto commiting changes',
                cmdd=dict(
                    cmd='git commit -m "%s %s auto commit"' % (
                        hostname, IDENT
                    ),
                    cwd=self.local
                ),
                more=changes
            )

            self.branch = None

            self.m(
                'auto merging branches',
                cmdd=dict(
                    cmd='git merge %s -m "%s %s auto merge"' % (
                        hostname, hostname, IDENT
                    ),
                    cwd=self.local
                ),
                more=dict(
                    branch=old_branch,
                    temp_branch=hostname
                )
            )

            self.branch = old_branch
        return dict(changes=changes, pull=self._pull())