Compare commits

...

40 commits

Author SHA1 Message Date
Fakerr a6de1b235c update helper 2021-04-22 22:42:01 +01:00
Walid Berrahal ae3ed35a06
Merge pull request #38 from josh-byster/patch-1
Update README to clarify permissions
2018-03-24 15:13:49 +01:00
Josh Byster 436a31cea1
Update README to clarify permissions
If a user is not sure about how to change permission access, I added a line for clarification.
2018-03-24 03:53:47 -05:00
Fakerr 7a41403687 version patch 2018-01-07 23:24:05 +01:00
Fakerr c00f10a39e 1.2.4 2018-01-07 23:23:08 +01:00
Walid Berrahal d18d910300
Merge pull request #37 from Seanmcn/master
Allow limiting history to path/s or file/s
2018-01-07 23:20:50 +01:00
Sean McNamara cf6849dfc6
Add -p parameter to README.md options 2018-01-05 15:33:21 +00:00
Sean McNamara 2a5db45188 Add option to specify file name/s or path/s to limit history to 2018-01-05 07:28:50 -08:00
Fakerr b8b00c832a 1.2.3 2017-09-04 16:02:53 +01:00
Fakerr f56c9309c6 version patch 2017-09-04 16:02:42 +01:00
Fakerr 740173deeb fix indentation 2017-09-04 16:02:17 +01:00
Walid Berrahal fa1f9036ba Merge pull request #36 from ryanc414/branch_option
Add option to specify branch name
2017-09-04 16:00:25 +01:00
Ryan Collingham 83496bf8c5 Add option to specify branch name 2017-09-03 21:49:38 +01:00
Walid Berrahal 47e6d4eb15 Merge pull request #35 from RonaldFindling/patch-1
Add -v parameter to README.md options
2017-08-27 12:03:08 +01:00
Ronald Findling 47bbdaddbb Add -v parameter to README.md options
This parameter is missing a description in README.md
2017-08-27 11:24:25 +02:00
Fakerr acc413e8a1 1.2.2 2017-08-15 12:30:44 +01:00
Fakerr 91776f73ca update version 2017-08-15 12:30:27 +01:00
Fakerr 39fccbbc6e some refactoring 2017-08-15 12:30:00 +01:00
Fakerr 72822bb787 untrap Ctrl-c while in less mode 2017-08-15 12:21:41 +01:00
Walid Berrahal db51c14ad9 Merge pull request #34 from ryanc414/fix/ctrl_c
Handle Ctrl-C interrupt
2017-08-15 12:18:11 +01:00
Walid Berrahal e2fb61c533 Merge pull request #20 from jong/no-merges
Automatically exclude merge commits when recalling.
2017-08-15 12:14:43 +01:00
Ryan 35ac6970af Restore original stty settings 2017-08-01 22:17:48 +01:00
Ryan Collingham a6fce2c863 Remove unintended whitespace changes 2017-07-24 10:33:16 +01:00
Ryan Collingham be62cc387d Merge branch 'master' into fix/ctrl_c 2017-07-24 10:27:18 +01:00
Fakerr 11a51477c3 remove line 2017-07-23 19:54:20 +01:00
Fakerr a177fb00f0 Merge branch 'master' of https://github.com/Fakerr/log-so-handy 2017-07-23 19:48:47 +01:00
Fakerr 594f2bdca8 1.2.1 2017-07-23 19:47:44 +01:00
Fakerr 42faeda992 patch v1.2.1 2017-07-23 19:47:37 +01:00
Fakerr 515dd02680 change tmp file's destination 2017-07-23 19:46:58 +01:00
Ryan Collingham 8db954a2d6 Cleanup diff gracefully 2017-07-17 11:52:21 +01:00
Ryan Collingham d7aa17d02c Trap ctrl-c and clean up 2017-07-16 17:29:22 +01:00
Walid Berrahal 8638fe7960 Merge pull request #33 from kiela/master
Allow to override Makefile prefix variables
2017-06-16 15:17:50 +01:00
Kamil Kieliszczyk 135cb9a195
Allow to override Makefile prefix variables 2017-06-16 15:04:28 +02:00
Walid Berrahal 9c5302802b Merge pull request #25 from expobrain/readme
Updated README
2017-06-11 21:15:56 +01:00
Fakerr bf75cc2972 1.2.0 2017-06-11 19:47:59 +01:00
Fakerr 16623b8537 1.1.13 2017-06-11 19:46:54 +01:00
Walid Berrahal 103fb21cfa Merge pull request #32 from Fakerr/mac-fix
fix mac os issues
2017-06-11 19:45:50 +01:00
Fakerr 17342d8c35 fix mac os issues 2017-06-11 19:44:19 +01:00
Daniele Esposti 408c8b66f6 Updated README 2017-03-29 10:45:47 +01:00
Jon Gartman 5950fd8ba7 Automatically exclude merge commits when recalling. 2017-01-30 16:34:23 -08:00
4 changed files with 79 additions and 42 deletions

View file

@ -1,5 +1,5 @@
PREFIX = /usr/local
BINPREFIX = "$(PREFIX)/bin"
PREFIX ?= /usr/local
BINPREFIX ?= "$(PREFIX)/bin"
LIB=git-recall

View file

@ -7,25 +7,31 @@
## Purpose
`git-recall` is a simple tool that allows you to easily go through your commits and
check what you or other contributors in your team did. It doesn't aim to be a replacement for the
check what you or other contributors in your team did. It doesn't aim to be a replacement for the
`git log` command, but just to be a convenient way to recall what you've done from your terminal.
## Usage
```sh
$ git recall [-a <author name>]
[-d <days-ago>]
$ git recall [-a <author name>]
[-d <days-ago>]
[-b <branch name>]
[-p <paths>]
[-f]
[-h]
[-v]
```
##### Options description:
- `-a` - Restrict search for a specific user (use -a "all" for all users)
- `-d` - Display commits for the last n days
- `-b` - Specify branch to display commits from
- `-p` - Specify path/s or file/s to display commits from
- `-f` - Fetch the latest changes
- `-h` - Show help screen
- `-v` - Show version
##### How to use:
@ -65,10 +71,10 @@ $ git recall -f
##### Without using tools
```
You can install it by simply copying the `git-recall` script into any existing path
(e.g. /usr/local/bin) or create your own directory and add it to the 'PATH' variable.
```
(e.g. `/usr/local/bin`) or create your own directory and add it to the `PATH` variable.
Make sure to run `chmod +x /usr/local/bin/git-recall` or the directory in which you copied it to.
##### Using NPM
Use `npm` to install the project.
@ -86,6 +92,7 @@ $ sudo make install
```
## Requirements
- OS: Linux or OSX
- Bash 4.3 or more
- Tools: git, less, sed
##### Optional Requirements

View file

@ -7,7 +7,9 @@ usage() {
Usage: git recall [options]
Options:
-d, --date Show logs for last n days.
-a, --author Author name.
-a, --author Author name (use -a "all" for all users).
-b, --branch Specify branch to display commits from.
-p --path Specify path or filename to display commits from.
-f, --fetch fetch commits.
-h, --help This message.
-v, --version Show version.
@ -16,6 +18,7 @@ EOF
}
# Global variables
orig_stty=$(stty -g) # Store original terminal settings
AUTHOR=""
FETCH=false
GIT_FORMAT=""
@ -23,9 +26,11 @@ GIT_LOG=""
COMMITS=""
SINCE="1 days ago" # show logs for last day by default
COMMITS_UNCOL=() # commits without colors
SED_BIN="" # Sed option to use according OS.
SED_CMD="" # Sed command to use according OS.
LESSKEY=false
VERSION="1.1.12"
VERSION="1.2.4"
BRANCH=""
SEARCH_PATH=""
# Set key bindings.
au="`echo -e '\e[A'`" # arrow up
@ -37,7 +42,7 @@ ad_1="j" # arrow down
nl_1="e" # expand
# Colored output.
colored() {
function colored() {
GREEN=$(tput setaf 4)
YELLOW=$(tput setaf 3)
NORMAL=$(tput sgr0)
@ -45,13 +50,19 @@ colored() {
}
# Uncolored output.
uncolored() {
function uncolored() {
GREEN=""
YELLOW=""
NORMAL=""
REVERSE=""
}
# Clear screen from cursor to end of screen
function clear_screen() {
echo -e "\E[J"
tput cuu1
}
# Are we in a git repo?
if [[ ! -d ".git" ]] && ! git rev-parse --git-dir &>/dev/null; then
echo "abort: not a git repository." 1>&2
@ -80,6 +91,14 @@ while [[ "$1" =~ ^- && ! "$1" == "--" ]]; do
usage
exit
;;
-b | --branch )
BRANCH="$2"
shift
;;
-p | --path )
SEARCH_PATH="$2"
shift
;;
* )
echo "abort: unknown argument" 1>&2
exit 1
@ -100,11 +119,6 @@ else
uncolored
fi
# Check if lesskey is installed.
if command -v lesskey &> /dev/null; then
LESSKEY=true
fi
# Set AUTHOR to current user if no param passed or display for all users if param equal to "all".
if [[ ! -n $AUTHOR ]]; then
AUTHOR=$(git config user.name 2>/dev/null)
@ -117,7 +131,7 @@ if [[ $FETCH == true ]]; then
echo "${GREEN}Fetching changes...${NORMAL}"
git fetch --all &> /dev/null
tput cuu1
tput ed # clear screen
clear_screen
fi
# Log template.
@ -126,7 +140,7 @@ GIT_FORMAT="%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%a
# Log command.
GIT_LOG="git log --pretty=format:'${GIT_FORMAT}'
--author \"$AUTHOR\"
--since \"$SINCE\" --abbrev-commit"
--since \"$SINCE\" --abbrev-commit --no-merges $BRANCH $SEARCH_PATH"
# Change temporary the IFS to store GIT_LOG's output into an array.
IFS=$'\n'
@ -148,16 +162,21 @@ if [[ $NI = 0 ]]; then
fi
fi
# Set correct sed option according OS's type
# Check if lesskey is installed.
if command -v lesskey &> /dev/null; then
LESSKEY=true
fi
# Set correct sed command according OS's type
case "$OSTYPE" in
darwin*) SED_BIN="sed -E" ;;
*) SED_BIN="sed -r" ;;
darwin*) SED_CMD="sed -E s/"$'\E'"\[([0-9]{1,2}(;[0-9]{1,2})*)?m//g" ;;
*) SED_CMD="sed -r s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" ;;
esac
# Create array with uncolred commits (removing escape sequences using sed)
for elt in "${COMMITS[@]}"
do
ELT="$(echo "$elt" | $SED_BIN "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g")" # remove colors escape codes
ELT="$(echo "$elt" | $SED_CMD)" # remove colors escape codes
COMMITS_UNCOL+=("$ELT")
done
@ -171,16 +190,16 @@ done
# Create a temporary lesskey file to change the keybindings so the user can use the TAB key to quit less. (more convenient)
if [[ $LESSKEY = true ]]; then
echo "\t quit" | lesskey -o $HOME/.lsh_less_keys_tmp -- - &> /dev/null
echo "\t quit" | lesskey -o /tmp/lsh_less_keys_tmp -- - &> /dev/null
fi
# Get commit's diff.
function get_diff() {
ELT="$(echo "${COMMITS_UNCOL[$CP-1]}")"
DIFF_TIP=${ELT:0:7}
DIFF_CMD="git show $DIFF_TIP --color=always"
DIFF_CMD="git show $DIFF_TIP --color=always $SEARCH_PATH"
DIFF=$(eval ${DIFF_CMD} 2>/dev/null)
tmp_diff="$(echo "$DIFF" | $SED_BIN "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g")"
tmp_diff="$(echo "$DIFF" | $SED_CMD)"
off=$(echo "$tmp_diff" | grep -c ".\{$CN\}") # Number of lines in the diff that are longer than terminal width.
DIFF_LINES_NUMBER="$(echo "$DIFF" | wc -l)"
DIFF_LINES_NUMBER=$(( DIFF_LINES_NUMBER + off ))
@ -190,15 +209,17 @@ function get_diff() {
function print_diff() {
get_diff
if [[ $(( TN + DIFF_LINES_NUMBER + OFFSET )) -ge $(( `tput lines` - 1 )) ]]; then
trap - INT
if [[ $LESSKEY = true ]]; then
echo "$DIFF" | less -r -k $HOME/.lsh_less_keys_tmp
echo "$DIFF" | less -r -k /tmp/lsh_less_keys_tmp
else
echo "$DIFF" | less -r
fi
tput ed # Clear screen
trap cleanup_and_exit INT
clear_screen
else
stop=false
tput ed
clear_screen
for i in `seq 1 $TN`
do
echo -n "$NORMAL"
@ -220,8 +241,7 @@ function print_diff() {
;;
esac
done
[[ $END = false ]] && tput cuu $(( TN + DIFF_LINES_NUMBER + OFFSET )) && tput ed
[[ $END = true ]] && tput cuu 1
[[ $END = false ]] && tput cuu $(( TN + DIFF_LINES_NUMBER + OFFSET )) && clear_screen
fi
}
@ -241,6 +261,21 @@ function calculate_offset {
done
}
# Reset changes made by this script before exiting
function cleanup_and_exit() {
# remove temporary less keybindings
[[ $LESSKEY = true ]] && rm /tmp/lsh_less_keys_tmp
tput cuu 1 # move cursor up one line. (remove extra line)
tput cnorm # unhide cursor
echo "$NORMAL" # normal colors
stty "$orig_stty" > /dev/null 2>&1
exit
}
# Catch a control-C interrupt and perform cleanup operations before exiting
trap cleanup_and_exit INT
{ # capture stdout to stderr
tput civis # hide cursor.
@ -291,7 +326,7 @@ do
[[ $TN != $(( SN - 1 )) ]] && tput cuu $(( TN + OFFSET_2 ))
[[ $TN == $(( SN - 1 )) ]] && tput cuu $(( TN + EXT ))
[[ $SI != 1 ]] && tput ed # clear screen
[[ $SI != 1 ]] && clear_screen
;;
"$ad" | "$ad_1")
CP=$(( CP + 1 ))
@ -300,8 +335,8 @@ do
[[ $TN != $(( SN - 1 )) ]] && tput cuu $(( TN + OFFSET_2 ))
[[ $TN == $(( SN - 1 )) ]] && tput cuu $(( TN + EXT ))
[[ $SI != 1 ]] && tput ed # clear screen
[[ $SI = 1 ]] && [[ $CP = 1 ]] && tput ed # clear screen
[[ $SI != 1 ]] && clear_screen
[[ $SI = 1 ]] && [[ $CP = 1 ]] && clear_screen
;;
"$nl" | "$nl_1")
[[ $TN == $NI ]] && tput cuu $(( TN + OFFSET_2 ))
@ -311,18 +346,13 @@ do
"q")
si=false
END=true
tput cuu 1 #move cursor up one line. (remove extra line)
;;
* )
tput cuu $(( TN + OFFSET_2 ))
esac
done
# remove temporary less keybindings
[[ $LESSKEY = true ]] && rm $HOME/.lsh_less_keys_tmp
tput cnorm # unhide cursor
echo "$NORMAL" # normal colors
cleanup_and_exit
} >&2 # END capture

View file

@ -1,6 +1,6 @@
{
"name": "git-recall",
"version": "1.1.12",
"version": "1.2.4",
"description": "Simple and convenient Git tool to easily recall what you've done",
"main": "",
"scripts": {