def _run(self):
        args = self.args

        def notes(noteArgs, **kwargs):
            gitArgs = 'notes --ref=%s %s %s' % (noteNamespace, noteArgs, args.commit)
            return git(gitArgs, **kwargs)

        def add(note):
            notes('add -fm "%s"' % note)

        note = notes('show', errorValue='')

        if args.delete:
            if not note:
                return
            workitem = args.workitem
            if workitem:
                items = note.split(',')
                try:
                    items.remove(str(workitem))
                except ValueError:
                    fail('Workitem %s is not associated with %s' % (workitem, args.commit))
                if items:
                    add(','.join(items))
                    return
            notes('remove')

        elif args.workitem:
            if note:
                note += ','
            add(note + str(args.workitem))
        elif note:
            print(note)
dataset/ETHPy150Open nodirt/git-tf/wi.py/wi._run/original