-
Notifications
You must be signed in to change notification settings - Fork 243
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
replaced git-standup with gitlog #18
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
e159030
replaced git-standup with gitlog
mojoaxel a2f3250
removed git-standup dependencie
mojoaxel 83da292
added myself as contributor ;-)
mojoaxel 8cff4ac
reverted: added myself as contributor ;-)
mojoaxel ed9f20e
also get gitlogs also from subdirs up to a given depth
mojoaxel 36cb216
Merge branch 'master' into gitlog
mojoaxel 2146858
updated README
mojoaxel cf3ecc8
updated subdirs release
mojoaxel f38f9fd
added error handling
mojoaxel d349d8d
Merge remote-tracking branch 'upstream/master' into gitlog
mojoaxel 752a227
Merge branch 'master' into gitlog
mojoaxel 29a7b70
Merge branch 'gitlog' of github.com:mojoaxel/tiny-care-terminal into …
mojoaxel 878fea1
seperated gitbot into own module;
mojoaxel b30df8b
Merge branch 'master' into gitlog
mojoaxel df56ba5
fixed emty commit list
mojoaxel 6922c43
@notwaldorf review comments
mojoaxel 3eebc08
Merge branch 'master' into gitlog
mojoaxel 4bc9a05
added repo name to commit history
mojoaxel 1aed41b
do not hide commits while reloading
mojoaxel 3f3886d
make it possible to switch between git-standup and gitlog
mojoaxel 294657b
filter pure administrative commits
mojoaxel 4cf5e21
readded git-stanup as peerDependency
mojoaxel 86caaa0
use existing git-standup implementation
mojoaxel 7d6ed23
Merge branch 'master' into gitlog
mojoaxel f945c1e
Merge branch 'master' into gitlog
mojoaxel e1ded0d
Merge branch 'gitlog' of github.com:mojoaxel/tiny-care-terminal into …
mojoaxel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
const gitUsername = require('git-user-name')(); | ||
const resolve = require('resolve-dir'); | ||
const subdirs = require('subdirs'); | ||
const isGit = require('is-git'); | ||
const gitlog = require('gitlog'); | ||
const path = require('path'); | ||
const async = require("async"); | ||
|
||
/** | ||
* Go through all `repos` and look for subdirectories up to a given `depth` | ||
* and look for repositories. | ||
* Calls `callback` with array of repositories. | ||
*/ | ||
function findGitRepos(repos, depth, callback) { | ||
let allRepos = []; | ||
async.each(repos, (repo, repoDone) => { | ||
repo = resolve(repo); | ||
subdirs(repo, depth, (err, dirs) => { | ||
if (err) { | ||
switch (err.code) { | ||
case 'ENOENT': | ||
return callback(`Could not open directory directory: ${err.path}\n`, null); | ||
case 'EACCES': | ||
return; //ignore if no access | ||
default: | ||
return callback(`Error "${err.code}" doing "${err.syscall}" on directory: ${err.path}\n`, null); | ||
} | ||
} | ||
if (dirs) dirs.push(repo); | ||
async.each(dirs, (dir, dirDone) => { | ||
isGit(dir, (err, isGit) => { | ||
if (err) { | ||
return callback(err, null); | ||
} | ||
if (!dir.includes('.git') && isGit) { | ||
allRepos.push(dir); | ||
} | ||
dirDone(); | ||
}); | ||
}, repoDone); | ||
}); | ||
}, err => { | ||
callback(err, allRepos.sort().reverse()); | ||
}); | ||
} | ||
|
||
/** | ||
* returns all commits of the last given `days`. | ||
* Calls `callback` with line-seperated-strings of the formatted commits. | ||
*/ | ||
function getCommitsFromRepos(repos, days, callback) { | ||
let cmts = []; | ||
async.each(repos, (repo, repoDone) => { | ||
try { | ||
gitlog({ | ||
repo: repo, | ||
number: 100, //max commit count | ||
since: `${days} days ago`, | ||
fields: ['abbrevHash', 'subject', 'authorDateRel', 'authorName'], | ||
author: gitUsername | ||
}, (err, logs) => { | ||
// Error | ||
if (err) | ||
return callback(err, null); | ||
|
||
// Repo path | ||
if (logs.length >= 1) | ||
cmts.push(repo); | ||
|
||
// Commit | ||
logs.forEach(c => { | ||
if (c.status && c.status.length) | ||
cmts.push(`${c.abbrevHash} - ${c.subject} (${c.authorDateRel}) <${c.authorName.replace('@end@\n','')}>`); | ||
}); | ||
repoDone(); | ||
}); | ||
} catch(err) { | ||
callback(err, null); | ||
} | ||
}, err => { | ||
callback(err, cmts.length > 0 ? cmts.join('\n') : "Nothing yet. Start small!"); | ||
}); | ||
} | ||
|
||
module.exports.findGitRepos = findGitRepos; | ||
module.exports.getCommitsFromRepos = getCommitsFromRepos; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Awesome!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
git-standup is the default settings for now. Let's give the gitlog implementation a try on different platforms, maybe we can remove the whole bash-scripting stuff all together at some point!