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

feat: 🎸 added optional refcount flag #469

Closed
wants to merge 2 commits into from
Closed
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -149,6 +149,10 @@ Options include:
* Type: String
* Default: `#FFA66D`
* A hex color code to style Check It Out
* refCount
* Type: Number
* Default: `--count 500`
* Total number of references to show.

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

6 changes: 5 additions & 1 deletion src/app.js
Original file line number Diff line number Diff line change
@@ -48,16 +48,20 @@ const defaultConfig = {
],
sort: '-committerdate',
themeColor: '#FFA66D',
refCount: 500,
};

const conf = new Configstore(pkg.name, defaultConfig);

export const start = async args => {
let refCount;
if (args[0] === '-v' || args[0] === '--version') {
process.stdout.write(pkg.version + '\n');
process.exit(0);
} else if (args[0] === '--reset-config') {
conf.all = defaultConfig;
} else if (args[0] === '--count' && args[1]) {
refCount = args[1];
}

const gitLogArguments = conf.get('gitLogArguments');
@@ -345,7 +349,7 @@ export const start = async args => {
};

try {
state.setRemotes(await getRefData());
state.setRemotes(await getRefData(refCount));

state.setCurrentRemoteIndex(
state.remotes.findIndex(remote => remote.name === 'heads'),
9 changes: 5 additions & 4 deletions src/utils/git.js
Original file line number Diff line number Diff line change
@@ -27,8 +27,8 @@ export const closeGitResponse = () => {
*
* @returns {Promise<Remote[]>} payload and uniqueRemotes
*/
export const getRefData = async () => {
const refs = await getRefs();
export const getRefData = async refCount => {
const refs = await getRefs(refCount);

const remotes = [];

@@ -177,12 +177,13 @@ export const formatRemoteBranches = async output => {
*
* @return {Promise<Ref[]>} String list of each ref associated with repository.
*/
const getRefs = async () => {
const getRefs = async refCount => {
refCount = refCount ? refCount : conf.get('refCount');
const args = [
'for-each-ref',
`--sort=${conf.get('sort')}`,
'--format=%(refname)',
'--count=500',
`--count=${refCount}`,
];

return formatRemoteBranches(await execGit(args));