-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlseq-diff
executable file
·44 lines (34 loc) · 1.35 KB
/
lseq-diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
# lseq-diff — display all changes from the last n days
# Usage: lseq-diff 2
# Check if LOGSEQ_GRAPH env var is defined
if [ -z "$LOGSEQ_GRAPH" ]; then
echo "Error: LOGSEQ_GRAPH environment variable must be defined."
exit 1
fi
# Check if the number of days is provided as an argument
if [ -z "$1" ]; then
echo "Usage: $0 <number_of_days>"
exit 1
fi
# Define the number of days
DAYS_AGO="$1"
# Define patterns to ignore in diff content
IGNORE_PATTERN=${IGNORE_PATTERN:-"collapsed::|background-color::|card-repeats::|card-last-*|card-ease|card-next-*"}
# Define file extensions to ignore (space-separated)
IGNORE_EXTENSIONS="excalidraw DS_Store"
# Prepare the exclude patterns for the excluded file extensions
EXCLUDE_PATTERNS=""
for ext in $IGNORE_EXTENSIONS; do
EXCLUDE_PATTERNS="$EXCLUDE_PATTERNS :(exclude)*.$ext"
done
cd $LOGSEQ_GRAPH
# Find the commit from the specified number of days ago
COMMIT_FROM_DAYS_AGO=$(git rev-list -n 1 --before="$DAYS_AGO days ago" HEAD)
# Check if a commit was found
if [ -z "$COMMIT_FROM_DAYS_AGO" ]; then
echo "No commits found from $DAYS_AGO days ago."
exit 1
fi
# Get the diff from that commit to HEAD, preserving color, excluding specified files, and filter out lines matching the pattern
git diff --color=always "$COMMIT_FROM_DAYS_AGO" HEAD -- . $EXCLUDE_PATTERNS | grep --color=always -vE "$IGNORE_PATTERN"