Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools,meta: make AUTHORS reflect all the contributors #88

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Alexey Orlenko <eaglexrlnk@gmail.com>
Dmitry Borisov <dimon.durak@gmail.com> <Dimon Durak>
Mykola Bilochub <nbelochub@gmail.com>
Timur Shemsedinov <timur.shemsedinov@gmail.com>
Vlad Dziuba <dzyubavlad@gmail.com> <Dzyubavlad@gmail.com>
3 changes: 3 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Timur Shemsedinov <timur.shemsedinov@gmail.com>
Dmitry Borisov <dimon.durak@gmail.com>
Artem Chernenkiy <notthewhite@gmail.com>
Alexey Orlenko <eaglexrlnk@gmail.com>
Mykola Bilochub <nbelochub@gmail.com>
Vlad Dziuba <dzyubavlad@gmail.com>
5 changes: 2 additions & 3 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ JavaScript Transfer Protocol ("JSTP") is licensed for use as follows:
"""
MIT License

Copyright (c) 2016–2017 JSTP project authors
(see https://github.com/metarhia/JSTP/blob/master/AUTHORS for full list)
and other JSTP contributors.
Copyright (c) 2016–2017 JSTP contributors
(see https://github.com/metarhia/JSTP/blob/master/AUTHORS).

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
27 changes: 27 additions & 0 deletions tools/common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Common utilities used by tools
'use strict';

const childProcess = require('child_process');
const fs = require('fs');

const common = {};
module.exports = common;

common.getCommandOutput = (cmd) => {
const exec = common.promisify(childProcess.exec);
return exec(cmd).then((stdout, stderr) => {
if (stderr) console.error(stderr);
return stdout;
});
};

common.promisify = (fn) => (...args) => (
new Promise((resolve, reject) => {
fn(...args, (error, ...result) => {
if (error) reject(error);
else resolve(...result);
});
})
);

common.writeFile = common.promisify(fs.writeFile);
24 changes: 2 additions & 22 deletions tools/prepare-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

'use strict';

const childProcess = require('child_process');
const fs = require('fs');
const https = require('https');
const path = require('path');

const { getCommandOutput, writeFile } = require('./common');

const commandName = path.relative('.', __filename);
const help = `\
This tool allows to filter the result of
Expand Down Expand Up @@ -83,14 +83,6 @@ getCommandOutput('git cherry ' + branch).then((cherryOut) => {
process.exit(1);
});

function getCommandOutput(cmd) {
const exec = promisify(childProcess.exec);
return exec(cmd).then((stdout, stderr) => {
if (stderr) console.error(stderr);
return stdout;
});
}

function getMetadata(commitHash) {
const command = 'git log --format="%aN%n%B" -n 1 ' + commitHash;
return getCommandOutput(command).then((output) => {
Expand Down Expand Up @@ -188,17 +180,6 @@ function getStreamData(stream, callback) {
stream.on('error', callback);
}

function promisify(fn) {
return (...args) => (
new Promise((resolve, reject) => {
fn(...args, (error, ...result) => {
if (error) reject(error);
else resolve(...result);
});
})
);
}

function processCommits(commits) {
commits = filterCommits(commits, maxLevel);

Expand Down Expand Up @@ -233,7 +214,6 @@ function processCommits(commits) {

script += '\n';

const writeFile = promisify(fs.writeFile);
return Promise.all([
writeFile(`${branch}-apply-commits.sh`, script),
writeFile(`${branch}-commits.md`, changelog)
Expand Down
22 changes: 22 additions & 0 deletions tools/update-authors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env node

'use strict';

const path = require('path');
const { getCommandOutput, writeFile } = require('./common');

const AUTHORS_PATH = path.resolve(__dirname, '..', 'AUTHORS');

getCommandOutput('git log --reverse --format="%aN <%aE>"').then((out) => {
const authors = [];
for (const author of out.split('\n')) {
if (!authors.includes(author)) {
authors.push(author);
}
}
return writeFile(AUTHORS_PATH, authors.join('\n'));
}).catch((error) => {
const message = error.stack || error.toString();
console.error(message);
process.exit(1);
});