Skip to content

Commit

Permalink
feat: 🎸 added optional refcount flag
Browse files Browse the repository at this point in the history
refcount optional flag added

BREAKING CHANGE: 🧨 No

✅ Closes: jwu910#464
  • Loading branch information
mhegde-fala committed Feb 21, 2020
1 parent 1948d18 commit b62eca1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,18 @@ Options include:
* Type: String
* Default: `#FFA66D`
* A hex color code to style Check It Out
* refCount
* Type: Number
* Default: `500`
* Total number of references to show.

To set `refCount` , start with the flag `--count`

```
checkit --count 20
OR
checkit --count=20
```

To reset Check It Out to its original configurations listed above, start with the flag `--reset-config`:

Expand Down
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

const app = require('./dist/app');

app.start(process.argv.slice(2)).catch(error => {
const args = process.argv
.slice(2)
.map(arg => arg.split('='))
.reduce((acc, val) => acc.concat(val), []); // support both "--key=val" and "key val"
app.start(args).catch(error => {
console.error(error);
process.exit(1);
});
5 changes: 4 additions & 1 deletion src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const defaultConfig = {
],
sort: '-committerdate',
themeColor: '#FFA66D',
refCount: 500,
};

const conf = new Configstore(pkg.name, defaultConfig);
Expand All @@ -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]));
}

const gitLogArguments = conf.get('gitLogArguments');
Expand Down Expand Up @@ -315,7 +318,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) || [])
.filter(ref => ref.name.search(state.filterRegex) !== -1)
.map(ref => [
ref.active ? '*' : ' ',
Expand Down
2 changes: 1 addition & 1 deletion src/utils/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ const getRefs = async () => {
'for-each-ref',
`--sort=${conf.get('sort')}`,
'--format=%(refname)',
'--count=500',
`--count=${conf.get('refCount')}`,
];

return formatRemoteBranches(await execGit(args));
Expand Down

0 comments on commit b62eca1

Please sign in to comment.