summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-09 13:38:02 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-09 13:38:02 +0000
commit6f442e774b9236c999f36c2d7af17640f49bff99 (patch)
tree47e73755bffd41bdde2d59d76cc595f5a1fa75d4 /tools
parentInitial commit. (diff)
downloadgitlint-6f442e774b9236c999f36c2d7af17640f49bff99.tar.xz
gitlint-6f442e774b9236c999f36c2d7af17640f49bff99.zip
Adding upstream version 0.19.1.upstream/0.19.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-xtools/changelog.py51
-rwxr-xr-xtools/create-test-repo.sh35
-rwxr-xr-xtools/stats.sh45
-rw-r--r--tools/windows/create-test-repo.bat37
-rw-r--r--tools/windows/run_tests.bat15
5 files changed, 183 insertions, 0 deletions
diff --git a/tools/changelog.py b/tools/changelog.py
new file mode 100755
index 0000000..24b74a8
--- /dev/null
+++ b/tools/changelog.py
@@ -0,0 +1,51 @@
+# ruff: noqa: T201 (Allow print statements)
+# Simple script to generate a rough changelog from git log.
+# This changelog is manually edited before it goes into CHANGELOG.md
+
+import re
+import subprocess
+import sys
+from collections import defaultdict
+
+if len(sys.argv) != 2:
+ print("Usage: python changelog.py <tag>")
+ sys.exit(1)
+
+tag = sys.argv[1]
+# Get all commits since the last release
+cmd = ["git", "log", "--pretty=%s|%aN", f"{tag}..HEAD"]
+log_lines = subprocess.Popen(cmd, stdout=subprocess.PIPE).stdout.read().decode("UTF-8")
+log_lines = log_lines.split("\n")[:-1]
+
+# Group commits by type
+commit_groups = defaultdict(list)
+for log_line in log_lines:
+ message, author = log_line.split("|")
+ # skip dependabot commits
+ if author == "dependabot[bot]":
+ group = "dependabot"
+ else:
+ type_parts = message.split(":")
+ if len(type_parts) == 1:
+ group = "other"
+ else:
+ group = type_parts[0]
+
+ commit_groups[group].append((message, author))
+
+# Print the changelog
+for group, commits in commit_groups.items():
+ print(group)
+ for message, author in commits:
+ # Thank authors other than maintainer
+ author_thanks = ""
+ if author != "Joris Roovers":
+ author_thanks = f" - Thanks {author}"
+
+ # Find the issue number in message using regex, format: (#1234)
+ issue_number = re.search(r"\(#(\d+)\)", message)
+ if issue_number:
+ issue_url = f"https://github.com/jorisroovers/gitlint/issues/{issue_number.group(1)}"
+ message = message.replace(issue_number.group(0), f"([#{issue_number.group(1)}]({issue_url}))")
+
+ print(f" - {message}{author_thanks}")
diff --git a/tools/create-test-repo.sh b/tools/create-test-repo.sh
new file mode 100755
index 0000000..5fddf8c
--- /dev/null
+++ b/tools/create-test-repo.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+RED="\033[31m"
+YELLOW="\033[33m"
+BLUE="\033[94m"
+GREEN="\033[32m"
+NO_COLOR="\033[0m"
+
+CWD="$(pwd)"
+echo "pwd=$CWD"
+# Create the repo
+cd /tmp
+reponame=$(date +gitlint-test-%Y-%m-%d_%H-%M-%S)
+git init --initial-branch main $reponame
+cd $reponame
+
+# Do some basic config
+git config user.name gïtlint-test-user
+git config user.email gitlint@test.com
+git config core.quotePath false
+git config core.precomposeUnicode true
+
+# Add a test commit
+echo "tëst 123" > test.txt
+git add test.txt
+# commit -m -> use multiple -m args to add multiple paragraphs (/n in strings are ignored)
+git commit -m "test cömmit title" -m "test cömmit body that has a bit more text"
+cd $CWD
+
+# Let the user know
+echo ""
+echo -e "Created $GREEN/tmp/${reponame}$NO_COLOR"
+echo "Hit key up to access 'cd /tmp/$reponame'"
+echo "(Run this script using 'source' for this to work)"
+history -s "cd /tmp/$reponame"
diff --git a/tools/stats.sh b/tools/stats.sh
new file mode 100755
index 0000000..ada2658
--- /dev/null
+++ b/tools/stats.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+# Script that displays some interesting stats about the gitlint project (LOC, # commits, downloads, etc)
+
+BLUE="\033[94m"
+NO_COLOR="\033[0m"
+
+title(){
+ echo -e "$BLUE=== $1 ===$NO_COLOR"
+}
+
+title Code
+radon raw -s gitlint-core | tail -n 11 | sed 's/^ //'
+
+title Docs
+echo "Markdown: $(cat docs/*.md | wc -l | tr -d " ") lines"
+
+title Tests
+nr_unit_tests=$(py.test gitlint-core/ --collect-only | grep TestCaseFunction | wc -l)
+nr_integration_tests=$(py.test qa/ --collect-only | grep TestCaseFunction | wc -l)
+echo "Unit Tests: ${nr_unit_tests//[[:space:]]/}"
+echo "Integration Tests: ${nr_integration_tests//[[:space:]]/}"
+
+title Git
+echo "Commits: $(git rev-list --all --count)"
+echo "Commits (main): $(git rev-list main --count)"
+echo "First commit: $(git log --pretty="%aD" $(git rev-list --max-parents=0 HEAD))"
+echo "Contributors: $(git log --format='%aN' | sort -u | wc -l | tr -d ' ')"
+echo "Releases (tags): $(git tag --list | wc -l | tr -d ' ')"
+latest_tag=$(git tag --sort=creatordate | tail -n 1)
+echo "Latest Release (tag): $latest_tag"
+echo "Commits since $latest_tag: $(git log --format=oneline HEAD...$latest_tag | wc -l | tr -d ' ')"
+echo "Line changes since $latest_tag: $(git diff --shortstat $latest_tag)"
+
+# PyPi API: https://pypistats.org/api/
+title PyPi
+info=$(curl -Ls https://pypi.python.org/pypi/gitlint/json)
+echo "Current version: $(echo $info | jq -r .info.version)"
+
+title "PyPI (Downloads)"
+overall_stats=$(curl -s https://pypistats.org/api/packages/gitlint/overall)
+recent_stats=$(curl -s https://pypistats.org/api/packages/gitlint/recent)
+echo "Last 6 Months: $(echo $overall_stats | jq -r '.data[].downloads' | awk '{sum+=$1} END {print sum}')"
+echo "Last Month: $(echo $recent_stats | jq .data.last_month)"
+echo "Last Week: $(echo $recent_stats | jq .data.last_week)"
+echo "Last Day: $(echo $recent_stats | jq .data.last_day)" \ No newline at end of file
diff --git a/tools/windows/create-test-repo.bat b/tools/windows/create-test-repo.bat
new file mode 100644
index 0000000..54cf146
--- /dev/null
+++ b/tools/windows/create-test-repo.bat
@@ -0,0 +1,37 @@
+
+:: Use pushd, so we can popd back at the end (directory changes are not contained inside batch file)
+PUSHD C:\Windows\Temp
+
+@echo off
+
+:: Determine unique git repo name
+:: We use Python to determine to get a datetime stamp since other workarounds in BATCH are locale dependent
+:: Note that we double escape the % in the format string to %%
+FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "import datetime; print(datetime.datetime.now().strftime('%%Y-%%m-%%d_%%H-%%M-%%S'))"`) DO (
+SET datetime=%%F
+)
+echo %datetime%
+set Reponame=gitlint-test-%datetime%
+echo %Reponame%
+
+:: Create git repo
+git init --initial-branch main %Reponame%
+cd %Reponame%
+
+:: Do some basic config
+git config user.name gïtlint-test-user
+git config user.email gitlint@test.com
+git config core.quotePath false
+git config core.precomposeUnicode true
+
+:: Add a test commit
+echo "tëst 123" > test.txt
+git add test.txt
+git commit -m "test cömmit title" -m "test cömmit body that has a bit more text"
+
+:: echo. -> the dot allows us to print an empty line
+echo.
+echo Created C:\Windows\Temp\%Reponame%
+
+:: Move back to original dir
+POPD \ No newline at end of file
diff --git a/tools/windows/run_tests.bat b/tools/windows/run_tests.bat
new file mode 100644
index 0000000..16ebc8b
--- /dev/null
+++ b/tools/windows/run_tests.bat
@@ -0,0 +1,15 @@
+@echo off
+
+set arg1=%1
+
+IF "%arg1%"=="-p" (
+ echo Running flake8...
+ flake8 --extend-ignore=H307,H405,H803,H904,H802,H701 --max-line-length=120 --exclude="*settings.py,*.venv/*.py" gitlint qa examples
+) ELSE (
+ :: Run passed arg, or all unit tests if passed arg is empty
+ IF "%arg1%" == "" (
+ pytest -rw -s gitlint
+ ) ELSE (
+ pytest -rw -s %arg1%
+ )
+) \ No newline at end of file