Skip to content

Add "Git for Windows" functionality #103

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ by adding the following to your .bashrc.
source ${REPO_PATH}/gi-completion.sh
```

If you are using Git for Windows, the "make" command may not be present. You can perform installation and other operations supported by the Makefile using the
gfw_inst.sh script. For example, to
install in a personal directory/folder, you can run:
```
PREFIX=/path/to/personal/install/ ./gfw-inst.sh install
```
The destination should be in your PATH environment variable for commands to work.

### Backward compatibility with the gi command
For backward compatibility you can also use the original _gi_ command,
by copying `gi.sh` to someplace in your path.
Expand Down
76 changes: 76 additions & 0 deletions gfw_inst.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/bin/bash

# Set default values if not already set
PREFIX="${PREFIX:-/usr/local}"
BINPREFIX="${BINPREFIX:-$PREFIX/bin}"
LIBPREFIX="${LIBPREFIX:-$PREFIX/lib}"
MANPREFIX="${MANPREFIX:-$PREFIX/share/man/man1}"
SYSCONFDIR="${SYSCONFDIR:-$PREFIX/etc}"

# Function to install
install_stuff() {
mkdir -p "${DESTDIR}${MANPREFIX}"
mkdir -p "${DESTDIR}${BINPREFIX}"
mkdir -p "${DESTDIR}${LIBPREFIX}/git-issue"
sed "s|/usr/local|${PREFIX}|g" git-issue.sh > git-issue
install git-issue "${DESTDIR}${BINPREFIX}/git-issue"
install lib/git-issue/import-export.sh "${DESTDIR}${LIBPREFIX}/git-issue/import-export.sh"
install -m 644 git-issue.1 "${DESTDIR}${MANPREFIX}/"
mkdir -p "${DESTDIR}${SYSCONFDIR}/bash_completion.d"
install -m 644 gi-completion.sh "${DESTDIR}${SYSCONFDIR}/bash_completion.d/git-issue"
}

# Function to synchronize documentation
sync-docs() {
./sync-docs.sh
}

# Function to run tests
runtests() {
if shellcheck --version >/dev/null 2>&1 ; then
shellcheck -x *.sh lib/git-issue/*.sh
else
echo 'Skipping shellcheck; consider installing it'
fi
./test.sh
}

# Function to uninstall
uninstall() {
rm -f "${DESTDIR}${BINPREFIX}/git-issue"
rm -f "${DESTDIR}${MANPREFIX}/git-issue."
rm -f "${DESTDIR}${SYSCONFDIR}/bash_completion.d/git-issue"
}

# Function to clean up files
clean() {
rm -f git-issue
}

# Main function to handle script calling logic
main() {
case "$1" in
install)
install_stuff
;;
sync-docs)
sync-docs
;;
test)
runtests
;;
uninstall)
uninstall
;;
clean)
clean
;;
*)
echo "Usage: $0 {install|sync-docs|test|uninstall|clean}"
exit 1
;;
esac
}

# Call main with all the arguments
main "$@"
16 changes: 16 additions & 0 deletions git-issue.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,22 @@ else
DATEBIN="date"
fi

# Function to determine the available pager
get_pager() {
if [ -n "$PAGER" ]; then
echo "$PAGER"
elif command -v more >/dev/null 2>&1; then
echo "more"
elif command -v less >/dev/null 2>&1; then
echo "less"
else
echo "cat"
fi
}

# Get the pager
PAGER=$(get_pager)

# Exit after displaying the specified error
error()
{
Expand Down