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

Code Review? #2

Closed
jbenet opened this issue May 14, 2015 · 13 comments
Closed

Code Review? #2

jbenet opened this issue May 14, 2015 · 13 comments

Comments

@jbenet
Copy link
Owner

jbenet commented May 14, 2015

Hey @chriscool, could you please take a look at this script?

thanks

@chriscool
Copy link
Contributor

@jbenet ok:

usage="USAGE
    $0 [--clean] <remote> <branch-prefix>

As <remote> and <branch-prefix> are optional, perhaps use the following:

usage="USAGE
    $0 [--clean] [<remote> [<branch-prefix>]]

@chriscool
Copy link
Contributor

Also the help/usage message could say what the default for <remote> and <branch-prefix> are.

@chriscool
Copy link
Contributor

It looks like it would not error out and maybe do funny things if passed more than 2 non option arguments, like with git-push-each foo bar baz.

@chriscool
Copy link
Contributor

I would also add a die() function like:

die() {
    echo >&2 "$@"
    exit 1
}

and use it to check that the push worked, like for example:

git push "$remote" "$spec" || die "Could not git push '$remote' '$spec'"

@chriscool
Copy link
Contributor

About [0-9a-f]{40}, I think it doesn't work when using uppercase letters from A to F in the hash, so you might want to add the -i, ignore case, switch when calling egrep, or use [0-9a-fA-F]{40} instead.

@chriscool
Copy link
Contributor

Otherwise it looks good to me. If you want I can have a look at providing patches for the above suggestions in the next days.

@chriscool
Copy link
Contributor

Also I am worried about what happens if git branch -r fails in this line:

 for line in $(git branch -r | egrep -wo "$remote/$spec" | egrep -o "$spec")

I think it would be better if the script would "die" if it fails.

@jbenet
Copy link
Owner Author

jbenet commented May 17, 2015

As and are optional, perhaps use the following:

SGTM 👍

Also the help/usage message could say what the default for and are.

SGTM 👍

It looks like it would not error out and maybe do funny things if passed more than 2 non option arguments, like with git-push-each foo bar baz.

Ah yes-- any good ideas there?

About [0-9a-f]{40}, I think it doesn't work when using uppercase letters from A to F in the hash, so you might want to add the -i, ignore case, switch when calling egrep, or use [0-9a-fA-F]{40} instead.

Ah yes, 👍

If you want I can have a look at providing patches for the above suggestions in the next days.

yes please!

Also I am worried about what happens if git branch -r fails in this line:
for line in $(git branch -r | egrep -wo "$remote/$spec" | egrep -o "$spec")
I think it would be better if the script would "die" if it fails.

Yeah entirely agreed.


@chriscool thanks so much-- this was a quick hack, and clearly not robust yet.

do you think it makes sense to test it with sharness?

@jbenet
Copy link
Owner Author

jbenet commented May 17, 2015

Oh and:

would also add a die() function like:
....
and use it to check that the push worked, like for example:

yep 👍

@chriscool
Copy link
Contributor

@jbenet I don't think it's worth adding sharness tests for this script for now. It is still quite small and not very sensitive.

@jbenet
Copy link
Owner Author

jbenet commented May 18, 2015

@jbenet I don't think it's worth adding sharness tests for this script for now. It is still quite small and not very sensitive.

yeah, my thoughts too. sounds good.

@jbenet jbenet mentioned this issue May 19, 2015
52 tasks
@chriscool
Copy link
Contributor

@jbenet can you close this now as PR #6 is merged?

@jbenet
Copy link
Owner Author

jbenet commented May 19, 2015

Yep! Thank you!

@jbenet jbenet closed this as completed May 19, 2015
@whyrusleeping whyrusleeping mentioned this issue May 26, 2015
49 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants