<commit_before>import grizzly from 'grizzly';
import currify from 'currify';
import tryToCatch from 'try-to-catch';

const isUndefined = (a) => typeof a === 'undefined';

export default currify(setTag);

const rmScope = (a) => a.replace(/^@.*\//, '');

async function setTag(version, info, chlog, emitter, callback) {
    if (!info.release && !isUndefined(info.release)) {
        emitter.emit('data', 'release: false\n');
        return callback();
    }
    
    const tag = 'v' + version;
    const user = getUser(info);
    const repo = getRepoName(info);
    const name = rmScope(info.name) + ' ' + tag;
    const body = chlog() || '';
    
    emitter.emit('data', `${user}/${repo}@${tag}\n`);
    emitter.emit('data', body);
    
    const data = {
        user,
        repo,
        tag,
        name,
        body,
    };
    
    const [error] = await tryToCatch(grizzly, null, data);
    
    if (!error) {
        emitter.emit('data', 'release: ok\n');
        callback();
    }
    
    emitter.emit('data', `Error releasing on github : ${error.message}. Trying again.\n`);
    await setTag(version, info, chlog, emitter, callback);
}

function getRepoName(json) {
    return json.repository.url
        .split('/')
        .pop()
        .replace('.git', '');
}

function getUser(json) {
    const FROM_USER = 3;
    const WITHOUT_REPO = -1;
    
    return json.repository.url
        .split('/')
        .slice(FROM_USER, WITHOUT_REPO)
        .pop();
}

<commit_msg>fix(wisdom) release: return when no error<commit_after>import grizzly from 'grizzly';
import currify from 'currify';
import tryToCatch from 'try-to-catch';

const isUndefined = (a) => typeof a === 'undefined';

export default currify(setTag);

const rmScope = (a) => a.replace(/^@.*\//, '');

async function setTag(version, info, chlog, emitter, callback) {
    if (!info.release && !isUndefined(info.release)) {
        emitter.emit('data', 'release: false\n');
        return callback();
    }
    
    const tag = 'v' + version;
    const user = getUser(info);
    const repo = getRepoName(info);
    const name = rmScope(info.name) + ' ' + tag;
    const body = chlog() || '';
    
    emitter.emit('data', `${user}/${repo}@${tag}\n`);
    emitter.emit('data', body);
    
    const data = {
        user,
        repo,
        tag,
        name,
        body,
    };
    
    const [error] = await tryToCatch(grizzly, null, data);
    
    if (!error) {
        emitter.emit('data', 'release: ok\n');
        return callback();
    }
    
    emitter.emit('data', `Error releasing on github : ${error.message}. Trying again.\n`);
    await setTag(version, info, chlog, emitter, callback);
}

function getRepoName(json) {
    return json.repository.url
        .split('/')
        .pop()
        .replace('.git', '');
}

function getUser(json) {
    const FROM_USER = 3;
    const WITHOUT_REPO = -1;
    
    return json.repository.url
        .split('/')
        .slice(FROM_USER, WITHOUT_REPO)
        .pop();
}


{'fraction_non_alphanumeric': 0.1674991674991675, 'fraction_numerical': 0.001332001332001332, 'mean_word_length': 2.4489092996555684, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1722834', 'n_tokens_mistral': 1001, 'n_tokens_neox': 995, 'n_words': 236}