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: check if inside of git repository before building #4363

Merged
merged 2 commits into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ MAKEFLAGS += --no-print-directory
# Secondary expansion is required for dependency variables in object rules.
.SECONDEXPANSION:

.PHONY: all rom clean compare tidy tools check-tools mostlyclean clean-tools clean-check-tools $(TOOLDIRS) $(CHECKTOOLDIRS) libagbsyscall agbcc modern tidymodern tidynonmodern check
.PHONY: all rom clean compare tidy tools check-tools mostlyclean clean-tools clean-check-tools $(TOOLDIRS) $(CHECKTOOLDIRS) libagbsyscall agbcc modern tidymodern tidynonmodern check history

infoshell = $(foreach line, $(shell $1 | sed "s/ /__SPACE__/g"), $(info $(subst __SPACE__, ,$(line))))

Expand Down Expand Up @@ -254,7 +254,10 @@ endif

AUTO_GEN_TARGETS :=

all: rom
all: history rom

history:
@bash ./check_history.sh

tools: $(TOOLDIRS)

Expand Down
35 changes: 35 additions & 0 deletions check_history.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

if [ -e .histignore ]
then
exit 0
fi

if [ $GITHUB_ACTION ]
then
exit 0
fi

has_hist=false
has_git=1
if which git >/dev/null
then
has_hist="$(git rev-parse --is-inside-work-tree 2>/dev/null)"
else
has_git=0
fi

if [ $has_git -ne 1 ]
then
echo -e "\033[0;31mfatal: \033[0m\033[1;33mgit was not found. You will be unable to use version control, update pokemon_expansion, or use feature branches. To use version control, install \`git\` and clone the repository instead of using \"Download Zip\" on GitHub. Run \`touch .histignore\` to ignore this and continue anyways.\033[0m"
AsparagusEduardo marked this conversation as resolved.
Show resolved Hide resolved
exit 1
fi

if [ "$has_hist" ]
then
exit 0
else
echo -e "\033[0;31mfatal: \033[0m\033[1;33mno git history found. You will be unable to use version control, update pokemon_expansion, or use feature branches. To use version control, use \`git\` to clone the repository instead of using \"Download Zip\" on GitHub. Run \`touch .histignore\` to ignore this and continue anyways.\033[0m"
AsparagusEduardo marked this conversation as resolved.
Show resolved Hide resolved
exit 1
fi

Loading