

@task
def commit():
    'git commit source changes from all tracked files\n\n    include:\n\n      - add all tracked files in the work tree, include modified(M), deleted(D)\n      - commit all files in the index, include added(A), modified(M),\n        renamed(R), deleted(D)\n      - untracked files should be manually added to the index before\n        run this task\n\n    before do commit, it requires to confirm the files to be committed; and\n    the requirement before do add is a future feature, it is currently\n    disabled.\n    '
    message = 'Update Documentation'
    yes_ans = ('y', 'yes')
    with settings(warn_only=True):
        add_file = '--update .'
        res = local('git diff --quiet --exit-code; echo $?', capture=True)
        if int(res.strip()):
            if False:
                test_res = local('git diff --name-status', capture=True)
                try:
                    _ans = raw_input('\n{0}\nAdd these files to index? (y/N) '.format(test_res.strip()))
                    if (_ans.lower() in yes_ans):
                        local('git add {0}'.format(add_file))
                except (KeyboardInterrupt, SystemExit):
                    pass
            else:
                local('git add {0}'.format(add_file))
        res = local('git diff --cached --quiet --exit-code; echo $?', capture=True)
        if int(res.strip()):
            test_res = local('git diff --cached --name-status', capture=True)
            try:
                _ans = raw_input('\n{0}\nCommit these files? (y/N) '.format(test_res.strip()))
                if (_ans.lower() in yes_ans):
                    local("git commit -m '{0}'".format(message))
            except (KeyboardInterrupt, SystemExit):
                pass
        else:
            print('Nothing to commit.')

dataset/ETHPy150Open tankywoo/simiki/simiki/conf_templates/fabfile.py commit/original