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

add *.csproj support to examples/gitserver/hooks/detect-language #12031

Merged
merged 1 commit into from
Nov 28, 2016
Merged
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
12 changes: 11 additions & 1 deletion examples/gitserver/hooks/detect-language
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ set -o pipefail
function has {
[[ -n $(git ls-tree --full-name --name-only HEAD ${@:1}) ]]
}
function hasglob {
git ls-tree --full-name --name-only HEAD | while read NAME; do
[[ "$NAME" == $1 ]] && return 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this going to compare "*.csproj" with "somefile.csproj" and fail? or is there some bash behavior here i'm not aware of?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latter, I believe. See bash(1) under [[ expression ]]: When the == and != operators are used, the string to the right of the operator is considered a pattern and matched according to the rules described below under Pattern Matching, as if the extglob shell option were enabled.

$ mkdir /tmp/empty && cd /tmp/empty
$ >bar.csproj
$ [[ "foo.csproj" == *.csproj ]] && echo yes
yes
$ [[ *.csproj == "foo.csproj" ]] && echo yes
$ [[ "foo.csproj" == "*.csproj" ]] && echo yes
$ [ "foo.csproj" == *.csproj ] && echo yes
$



Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i tested w/o the [[ ]] which is why it didn't work for me. looks good, thanks.

done
}
function key {
git config --local --get "${1}"
}
Expand Down Expand Up @@ -50,7 +55,12 @@ if has index.pl cpanfile; then
exit 0
fi

if has project.json; then
if has build.sbt; then
echo "${prefix}scala"
exit 0
fi

if has project.json || hasglob '*.csproj'; then
echo "${prefix}dotnet"
exit 0
fi
Expand Down