-
-
Notifications
You must be signed in to change notification settings - Fork 71
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
feat: 🎸 added optional refcount flag #469
Conversation
Just started reviewing :) |
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.
Thanks for the PR @mahendraHegde please take a look at my comments
@kienD Can you take a look at the implementation and see what you think around the use of options?
index.js
Outdated
app.start(process.argv.slice(2)).catch(error => { | ||
const args = process.argv | ||
.slice(2) | ||
.reduce((acc, val) => acc.concat(val.split('=')), []); // support both "key=val" and "key val" |
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.
We don't need to communicate the usage of this logic in an inline-comment
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'm also not 100% convinced we need to pre-process the flags right now. Can you explain the need?
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 is not necessary, only if you want to provide --count=2
this prepossessing is needed.
--count 2
will work just fine even without the preprocessing.
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 often use both the formats while providing args to CLI tools and most tools support it.
I'll remove it , if you think it is not necessary
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.
Adding to the conversation instead of the new commits: I don't think it is necessary in this case with as few arguments as we have. The way we currently have our options for CIO set up, its a very simple statement and will not work if we add more options in the future.
My reasoning for not wanting to add this line in is that when we get around to adding in a second option, this will break and we won't be able to parse options. I had plans to introduce a cli parsing library at that point. Though it would require some organization of this file.
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.
modified.
src/app.js
Outdated
@@ -58,6 +59,8 @@ export const start = async args => { | |||
process.exit(0); | |||
} else if (args[0] === '--reset-config') { | |||
conf.all = defaultConfig; | |||
} else if (args[0] === '--count' && args[1]) { | |||
conf.set('refCount', parseInt(args[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 creating a side effect of the flag option persisting. Is that the intention? I think options being passed should just act as an overriding flag for a single execution. If we need to persist options through the cli instead of editing the config file, then we can create a ticket to check for a persist/save option in the future.
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.
yes it was intentional, I'll modify it for a single execution then.
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 agree that this should be for single execution only.
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.
We will need to add error handling as well for cases where the end user uses a flag
but does not pass a value or passes an invalid value like... --count one
....etc..
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.
src/utils/git.js
Outdated
@@ -182,7 +182,7 @@ const getRefs = async () => { | |||
'for-each-ref', | |||
`--sort=${conf.get('sort')}`, | |||
'--format=%(refname)', | |||
'--count=500', | |||
`--count=${conf.get('refCount')}`, |
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.
To build on the comment about not changing the config object. When a user passes the option to override the count, i think we can use that over the options only when present, otherwise we can use the default options.
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.
modified accordingly.
README.md
Outdated
To set `refCount` , start with the flag `--count` | ||
|
||
``` | ||
checkit --count 20 | ||
OR | ||
checkit --count=20 |
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.
May not be necessary per my comments later in the review
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.
done
Side note before I finish reviewing, can you update your commit message? This is not a bug fix, the changes are still part of a feature addition. Thanks |
src/app.js
Outdated
@@ -315,7 +319,7 @@ export const start = async args => { | |||
* Update current screen with current remote | |||
*/ | |||
const refreshTable = () => { | |||
const tableData = state.currentRemote.refs | |||
const tableData = ((state.currentRemote && state.currentRemote.refs) || []) |
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.
What did you run into that prompted you to add this?
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.
if you give refCount value very low such as 1
, remotes may not have heads
and
here the currentRemote will be set to undefined and will result a crash.
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 this is an acceptable error and reason to crash. It only crashes if you attempt to select an item that does not exist--but effectively an edge case
The purpose of Check It Out is to change branches and if any user is using --count=1
there will only be one option to switch to, or no options depending on the first ref returned from the ref getter.
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.
are you suggesting we should let it crash @jwu910 ?
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.
Yes, the app does not crash on start, it crashes when you are selecting nothing essentially. But you wouldn't use CIO in this manner. The function you linked to is being invoked in a try-catch already.
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.
reverted.
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.
@jwu910 can you review? its been very long
e6d8ad5
to
bb61201
Compare
refcount optional flag added BREAKING CHANGE: 🧨 No ✅ Closes: jwu910#464
refCount should only be valid for current execution BREAKING CHANGE: 🧨 No ✅ Closes: jwu910#464
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@mahendraHegde I'll try to take a look when I get a chance. Been pretty busy lately with everything going on. It'll be a full fresh review though since it's been so long. /CC: @kienD |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically closed due to inactivity. If this issue has not been resolved, please reopen the issue. Thank you. |
no stale |
Fixes : #464
refcount optional flag added
BREAKING CHANGE: 🧨 No
Description
implemented an option for the --count option flag that gets passed into the git ref command that populates the list of references.
Types of changes
Checklist: