-
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
Conversation
This should also fix #17 |
The nice thing about this is that it also works on Windows! Yay, thank you! |
package.json
Outdated
@@ -4,6 +4,9 @@ | |||
"description": "A terminal that tries to take care of you 💖", | |||
"main": "care.js", | |||
"author": "Monica Dinculescu <[email protected]>", | |||
"contributors": [ |
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.
I haven't been doing this for anyone else who has been sending PRs, so I'm inclined to just have the GitHub contributors reflect this. WDYT?
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.
No problem at all! Let's keep the package.json slim 😉
I tried running your patch locally, but I get:
|
Ohhh I see. So the advantage of |
Good, point! I see if I can improve further... 🤘 |
@notwaldorf I introduced a new env var |
package.json
Outdated
"parrotsay-api": "^0.1.1", | ||
"scraperjs": "^1.2.0", | ||
"subdirs": "github:mojoaxel/subdirs", |
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.
This is not perfect. I'm waiting for jarofghosts/subdirs#2 to get merged and published...
@notwaldorf Ok, I now also updated the README and introduced some error handling ✨. Now you have to decide if you want to get rid of the script-based |
I really hope this will be the solution going forward, because the git-standup script version will never work on Windows. |
If Windows support with the helper script is needed that is certainly simple enough to be ported into a Windows script that can be executed based on the environment. No need to convert the entire subsystem over just for that. |
Are you sure about that? Replacing a dependency with a similar one (e.g. git-standup => gitlog) is hardly "convert[ing] the entire subsystem", and there are clear benefits in having a platform-independent, pure JS solution over having platform specific scripts written for different environments. (That's the whole point of node.js after all.) Yes, PowerShell is perfectly capable of what the current shell script is doing, but is a ps1 script really worth writing and maintaining? Especially considering the burden of having to update and test both scripts from now on for the rest of the project's lifetime, which won't be easy as it will require testing on at least two different operating systems. |
I never said it was a bad change, I simply was stating if Windows support is desired then this effort of changing the way the git logs are retrieved (the subsystem) is not entirely required. The script is simple enough to do in a native Windows shell to at least get some initial support until this solution can be more thoroughly looked over. From some experience in the Firefox's new HTML-based Debugger for their DevTools, handling git stuff well and in a compatible way through Node isn't always straightforward. Some care should be taken before rushing into it and then having quirky setups cause issues that need to be solved that otherwise aren't issues. |
care.js
Outdated
* and look for repositories. | ||
* Calls `callback` with array of repositories. | ||
*/ | ||
function getGitRepos(repos, depth, callback) { |
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.
It looks like PR #36 may land opening up more ES6 usage. It may be good to wait for that to land then refactor these extra functions into isolated modules to keep the main care file smaller.
care.js
Outdated
var blessed = require('blessed'); | ||
var contrib = require('blessed-contrib'); | ||
var chalk = require('chalk'); | ||
var parrotSay = require('parrotsay-api'); | ||
var bunnySay = require('sign-bunny'); | ||
var weather = require('weather-js'); | ||
|
||
console.dir(gitbot); |
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.
remove :)
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.
😱 sorry...gone
care.js
Outdated
@@ -1,15 +1,18 @@ | |||
#!/usr/bin/env node | |||
var config = require(__dirname + '/config.js'); | |||
var twitterbot = require(__dirname + '/twitterbot.js'); | |||
var gitbot = require(__dirname + '/gitbot.js'); |
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.
🙌
care.js
Outdated
} | ||
|
||
gitbot.findGitRepos(config.repos, config.reposDepth-1, (err, allRepos) => { | ||
if (err) return showError(err); |
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.
return
on a new line, please (here and everywhere)
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.
noproblemo
care.js
Outdated
} | ||
|
||
function showError(err, box) { | ||
getCommits(`😥 ${err}`, box); |
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.
Is this bit actually needed? For an error, can't we just do box.content = err
?
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.
good idea!
config.js
Outdated
repos: (process.env.TTC_REPOS || '~/Code').split(','), | ||
|
||
// The directory-depth on how to look for git-repos. Use with care! | ||
reposDepth: process.env.TTC_REPOS_DEPTH || 1, |
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.
this is already called depth
, below
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.
sorry...merges and stuff...will fix
I'll add the repos to the commits and think about a nice way for the transition! |
@notwaldorf I added the repo names. I also added a var 'TTC_GITBOT' to switch between |
Interesting: |
Update: I now also filter pure administrative commits like merges (gitlog has a attribute for that). |
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.
I think the gitlog is aces, and works great for me. My only concern is that along with adding gitlog
, this PR also changes the current behaviour of git-standup
, which means if people don't switch to gitlog
they might have new git-standup
problems they didn't have this PR, and I'd really like to not have that
care.js
Outdated
if (config.gitbot.toLowerCase() === 'gitstandup') { | ||
todayBox.content = ''; | ||
config.repos.forEach(repo => { | ||
var today = spawn(`cd ${repo} && git-standup`, [`-m ${config.depth}`, '-d 1'], {shell:true}); |
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.
uhhhhhh so I'm not 100% sure this works, because git-standup is on the wrong path (and works locally, but doesn't work when installed as a package). Can you just revert this, and leave the old git-standup behaviour, so that this PR just adds gitlog, and not other things? That way it's easier if something goes wrong after this PR :)
care.js
Outdated
}); | ||
weekBox.content = ''; | ||
config.repos.forEach(repo => { | ||
var today = spawn(`cd ${repo} && git-standup`, [`-m ${config.depth}`, '-d 7'], {shell:true}); |
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.
same here
care.js
Outdated
} else { | ||
gitbot.findGitRepos(config.repos, config.depth-1, (err, allRepos) => { | ||
if (err) | ||
return todayBox.content = err; |
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.
this won't call screen.render()
anywhere, will it?
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.
good point! I'll improve..
|
||
// Directory-depth to look for git repositories. | ||
depth: (process.env.TTC_REPOS_DEPTH || 1), | ||
|
||
// Which method is to be used to read the git commits ('gitstandup' | 'gitlog'). | ||
gitbot: (process.env.TTC_GITBOT || 'gitstandup'), |
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!
package.json
Outdated
"twit": "^2.2.5", | ||
"weather-js": "^2.0.0" | ||
}, | ||
"peerDependencies": { |
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.
pls add this back in
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.
@notwaldorf Wow! You actually reviewed this at #jsconfeu ! 🎉 Thx. I'll try to have a look tonight.
@notwaldorf Yo! Check this out! ;-) |
Awesome! YAY! Thanks! |
🎉 🎈 ! |
@KernelDeimos What's your node version? It seems like it isn't loving the ES6 keywords. |
Wow! Please update node.js to >= 6.10.3 |
My bad - I thought Ubuntu's repos would have it at least reasonably up-to-date :/ boy was I wrong Side note: Apparently I can't upgrade node.js without running some shell script from the Internet as root. I haven't found a single reference online that tells me I can just add something to my sources file... what's up with that? |
The only stable way to get a newer version without root access is Node Version Manager. It installs node versions into your user folder with your permissions. The os-level update from an external repository will need root access since in those cases you are editing your global software sources list and installing the new version. Generally running trusted scripts as root isn't a problem. You can always download the script and look it over before running it to see what it is doing. If you don't have root access (which is fairly uncommon, especially on workstation machines) then you'll need to go the NVM route. |
I replaced git-standup with gitlog.
This should solve issues #11 and #14 🎉
This is an alternative to #8.