Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b6f3c99
src: patch_track: Add initial files for kw patch-track
JGBSouza Apr 16, 2025
e4714df
src: patch_track: Adiciona nova funcao register_patch_track
JGBSouza Apr 20, 2025
a7e259a
src: patch_track: Add kw patch-track dashboard
JGBSouza Apr 20, 2025
7bfc810
src: patch_track: Add new feature set-status
JGBSouza Apr 21, 2025
50d49c2
add: adiciona novos modelos banco de dados
Sep 21, 2025
f14a1cb
save: evitando perder
Oct 5, 2025
1beb3da
pre registro patches
Oct 8, 2025
d64b015
fix: remove database unused attributes
JGBSouza Dec 23, 2025
6cde43f
feat: adiciona novas dependencias para o mutt
JGBSouza Dec 23, 2025
0ba85a9
feat: add new directories for mutt managment
JGBSouza Dec 23, 2025
eecde68
feat: add setup configs for mutt
JGBSouza Dec 23, 2025
8d24b07
feat: add init configs for mutt
JGBSouza Dec 23, 2025
cf92a9e
feat: add config loader to load mutt configs
JGBSouza Dec 23, 2025
4e23fe1
fix: fix select from and remove test prints
JGBSouza Dec 23, 2025
527977b
fix: flex string verification and add new function to check for valid…
JGBSouza Dec 23, 2025
849a476
feat: add new function ask with no default to kwio
JGBSouza Dec 23, 2025
c9403d4
fix: fix contribution_uutils functions
JGBSouza Dec 23, 2025
033950b
fix: fix patch_utils functions
JGBSouza Dec 23, 2025
3bc9caa
fix: fix submission_utils functions
JGBSouza Dec 23, 2025
a3fd18b
feat: ask contribution name in send_patch
JGBSouza Dec 23, 2025
eadbac3
feat: add mutt integration and open contribution and update contribut…
JGBSouza Dec 23, 2025
61bc3a4
feat: add contact_utils functions
JGBSouza Dec 23, 2025
3d83cf1
feat: add repository_utils functions
JGBSouza Dec 23, 2025
74d9f38
feat: add file with template configs for mutt
JGBSouza Dec 23, 2025
d9e5a07
fix: remove arquivos desnecessarios
JGBSouza Dec 27, 2025
1d8c268
fix: adiciona nova documentacao para o kw patch track
JGBSouza Dec 27, 2025
43561f4
fix: remove trechos de codigo desnecessarios
JGBSouza Dec 27, 2025
0a4e26b
feat: adiciona documentação para o kw patch_track
JGBSouza Dec 27, 2025
6ded46c
feat: adiciona comentários para o contact_utils
JGBSouza Dec 27, 2025
14435c9
feat: adiciona comentários de código para contribution_utils
JGBSouza Dec 27, 2025
99b16ee
feat: adiciona comentários de código para patch_utils
JGBSouza Dec 27, 2025
effa47a
feat: adiciona comentários de código para repository_utils
JGBSouza Dec 27, 2025
a68b93b
feat: adiciona comentários de código para submission_utils
JGBSouza Dec 27, 2025
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
88 changes: 88 additions & 0 deletions database/kwdb.sql
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,94 @@ CREATE TABLE IF NOT EXISTS "event" (
PRIMARY KEY("id")
);

-- This is the table that holds the events triggered by kw, currently pertains
-- to the executed commands that are saved and the pomodoro sessions created
CREATE TABLE IF NOT EXISTS "patch" (
"id" INTEGER,
"title" TEXT NOT NULL,
"author_email" TEXT,
"status" VARCHAR(50) DEFAULT ('SENT') NOT NULL,
"commit_hash" TEXT,
"created_at" TEXT DEFAULT (datetime('now','localtime')),
"contribution_id" INTEGER NOT NULL,
CHECK ("status" IN ('SENT', 'APPROVED', 'MERGED', 'REVIEWED', 'REJECTED')),
PRIMARY KEY("id"),
FOREIGN KEY ("contribution_id") REFERENCES "contribution"("id") ON DELETE CASCADE
);

CREATE TABLE IF NOT EXISTS "contribution_tag" (
"id" INTEGER,
"name" VARCHAR(50) NOT NULL UNIQUE,
PRIMARY KEY("id")
);

CREATE TABLE IF NOT EXISTS "contribution_tag_relation" (
"tag_id" INTEGER NOT NULL,
"contribution_id" INTEGER NOT NULL,
FOREIGN KEY ("tag_id") REFERENCES "patch_tag"("id") ON DELETE CASCADE,
FOREIGN KEY ("contribution_id") REFERENCES "contribution"("id") ON DELETE CASCADE,
UNIQUE("tag_id", "contribution_id")
);

CREATE TABLE IF NOT EXISTS "submission" (
"id" INTEGER,
"contribution_id" INTEGER NOT NULL,
"send_by" TEXT NOT NULL,
"created_at" TEXT DEFAULT (datetime('now','localtime')),
PRIMARY KEY("id"),
FOREIGN KEY ("contribution_id") REFERENCES "contribution"("id") ON DELETE CASCADE
);

CREATE TABLE IF NOT EXISTS "patch_submission" (
"patch_id" INTEGER NOT NULL,
"submission_id" INTEGER NOT NULL,
"message_id" TEXT NOT NULL,
"created_at" TEXT DEFAULT (datetime('now','localtime')),
PRIMARY KEY ("patch_id", "submission_id", "message_id"),
FOREIGN KEY ("submission_id") REFERENCES "submission"("id") ON DELETE CASCADE,
FOREIGN KEY ("patch_id") REFERENCES "patch"("id") ON DELETE CASCADE
);

CREATE TABLE IF NOT EXISTS "contribution" (
"id" INTEGER,
"title" TEXT NOT NULL,
"created_at" TEXT DEFAULT (datetime('now','localtime')),
"last_interaction_at" TEXT DEFAULT (datetime('now','localtime')),
"status" VARCHAR(50) DEFAULT ('SENT') NOT NULL,
"author_email" TEXT NOT NULL,
"repository_id" INTEGER,
UNIQUE("title", "author_email")
PRIMARY KEY("id"),
FOREIGN KEY ("repository_id") REFERENCES "repository"("id") ON DELETE CASCADE
);

CREATE TABLE IF NOT EXISTS "repository" (
"id" INTEGER,
"created_at" TEXT DEFAULT (datetime('now','localtime')),
"name" TEXT NOT NULL,
"origin_url" TEXT NOT NULL UNIQUE,
PRIMARY KEY("id")
);

CREATE TABLE IF NOT EXISTS "repository_maintainer" (
"id" INTEGER,
"repository_id" INTEGER NOT NULL,
"contact_id" INTEGER NOT NULL,
PRIMARY KEY("id"),
UNIQUE ("repository_id", "contact_id"),
FOREIGN KEY ("repository_id") REFERENCES "repository"("id") ON DELETE CASCADE,
FOREIGN KEY ("contact_id") REFERENCES "email_contact"("id") ON DELETE CASCADE
);

-- Table containing the kw email contacts infos
CREATE TABLE IF NOT EXISTS "email_contact" (
"id" INTEGER NOT NULL UNIQUE,
"name" VARCHAR(100) NOT NULL,
"email" VARCHAR(100) NOT NULL UNIQUE,
"created_at" TEXT DEFAULT (date('now', 'localtime')),
PRIMARY KEY("id")
);

-- This is the relationship between an "event" that executes a given
-- "command_label"
CREATE TABLE IF NOT EXISTS "executed" (
Expand Down
1 change: 1 addition & 0 deletions documentation/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@
('man/features/kw-self-update', 'kw-self-update', 'kw self-update mechanism', ['David Tadokoro, Everaldo Junior'], 1),
('man/features/kw-patch-hub', 'kw-patch-hub', 'Terminal UI to interact with patches from lore.kernel.org', ['David Tadokoro, Rodrigo Siqueira'], 1),
('man/features/kw-bd', 'kw-bd', 'build and then deploy the kernel', ['Briza Mel de Sousa, Lorenzo Salvador'], 1),
('man/features/kw-patch-track', 'kw-patch-track', 'track and display patches sent with kw-send-patch', ['João Guilherme Barbosa de Souza'], 1),
]


Expand Down
3 changes: 3 additions & 0 deletions documentation/dependencies/arch.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ procps-ng
pciutils
libnotify
python-sphinx
mutt
xvfb
xterm
4 changes: 4 additions & 0 deletions documentation/dependencies/debian.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ procps
pciutils
libnotify-bin
python3-sphinx
mutt
mutt
xvfb
xterm
3 changes: 3 additions & 0 deletions documentation/dependencies/fedora.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ procps-ng
pciutils
libnotify
python3-sphinx
mutt
xvfb
xterm
94 changes: 94 additions & 0 deletions documentation/man/features/kw-patch-track.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
==================================================================
kw-patch-track - Track and display patches sent with kw-send-patch
==================================================================

.. _patch-track-doc:

SYNOPSIS
========
| *kw patch-track* [OPTIONS]

DESCRIPTION
===========
The `kw patch-track` feature manages local tracking of patch submissions sent via
`kw send-patch`. It works by scraping metadata from submission logs to populate
a local database, keeping record of shipping dates, status, and titles.

Beyond simple visualization, it provides a heuristic engine to automatically
update patch statuses based on mailing list activity and allows for deep
integration with the `mutt` email client to facilitate review follow-ups.

OPTIONS
=======
--show-patches:
Displays the patches dashboard in chronological order, showing patch ID,
creation date, current status, and title.

-d, --show-contributions:
Displays the contributions dashboard, grouping sets of patches into higher-level
contribution entities.

-f <YYYY-MM-DD>, --from <YYYY-MM-DD>, -a <YYYY-MM-DD>, --after <YYYY-MM-DD>:
Filters the dashboard to display only patches created on or after the specified date.

-b <YYYY-MM-DD>, --before <YYYY-MM-DD>:
Filters the dashboard to display only patches created before the specified date.

--id <patch_id>:
Specifies a unique patch ID for status modification.

-s <status>, --set-status <status>:
Manually sets a new status for a specific patch (specified via --id).
Available statuses: SUBMITTED, REVIEWED, APPROVED, MERGED, REJECTED.

-u, --update:
Triggers the automated heuristic engine to update patch statuses by analyzing
associated email threads.

-c <contribution_id>, --contribution-id <contribution_id>:
Specifies the contribution ID to be used with repository or mutt operations.

--set-repository <name:url>:
Associates a repository name and its origin URL to a contribution.
Requires --contribution-id.

-r <repository_id>, --repository-id <repository_id>:
Specifies the repository ID to be used with maintainer operations.

-m <name:email>, --set-maintainer <name:email>:
Associates a maintainer's name and email to a specific repository.
Requires --repository-id.

-o, --open-contribution:
Opens the email thread associated with a contribution directly in the `mutt`
terminal client. Requires --contribution-id.

EXAMPLES
========
To view the chronological dashboard of all patches:

kw patch-track --show-patches

To view grouped contributions:

kw patch-track --show-contributions

To filter patches submitted within a specific timeframe:

kw patch-track --show-patches --after 2023-01-01 --before 2023-12-31

To manually update a patch status after a maintainer's feedback:

kw patch-track --id 42 --set-status APPROVED

To run the automatic status update heuristics:

kw patch-track --update

To link a contribution to a specific subsystem repository:

kw patch-track --contribution-id 10 --set-repository "linux-usb:https://git.kernel.org/..."

To open a specific contribution thread in mutt for review:

kw patch-track --contribution-id 10 --open-contribution
8 changes: 8 additions & 0 deletions etc/patch_track_mutt.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Mutt options to be used with patch-track
imap_user=
imap_pass=

folder="imaps://imap.gmail.com"
spoolfile="+[Gmail]/Todos os e-mails"
record="+[Gmail]/Sent Mail"
mbox_type="Maildir"
17 changes: 17 additions & 0 deletions kw
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ KW_DOC_DIR="${KW_SHARE_DIR}/doc"
KW_MAN_DIR="${KW_SHARE_DIR}/man"
KW_SOUND_DIR="${KW_SHARE_DIR}/sound"
KW_DB_DIR="${KW_SHARE_DIR}/database"
KW_MUTT_DIR="${KW_SHARE_DIR}/mutt"
KW_MUTT_MESSAGES_DIR="${KW_MUTT_DIR}/messages"
KW_MUTT_HEADERS_DIR="${KW_MUTT_DIR}/headers"

# Configuration files
KW_ETC_DIR="${XDG_CONFIG_HOME:-"${HOME}/.config"}/${KWORKFLOW}"
Expand Down Expand Up @@ -61,6 +64,9 @@ if [ -f "${KW_BASE_DIR}/src/lib/kwlib.sh" ]; then
KW_ETC_DIR="${KW_BASE_DIR}/etc"
KW_PLUGINS_DIR="${KW_LIB_DIR}/plugins"
KW_SRC_LIB_DIR="${KW_LIB_DIR}/lib"
KW_MUTT_DIR="${KW_BASE_DIR}/mutt"
KW_MUTT_MESSAGES_DIR="${KW_MUTT_DIR}/messages"
KW_MUTT_HEADERS_DIR="${KW_MUTT_DIR}/messages"
# KW_CACHE_DIR # use default cache folder
fi
##END-REPO-MODE##
Expand All @@ -85,6 +91,10 @@ if [[ "${KW_REPO_MODE}" == 'y' ]]; then
repo_mode_msg+=$'\t'"KW_CACHE_DIR=${KW_CACHE_DIR}"$'\n'
repo_mode_msg+=$'\t'"KW_DATA_DIR=${KW_DATA_DIR}"$'\n'
repo_mode_msg+=$'\t'"KW_DB_DIR=${KW_DB_DIR}"$'\n'
repo_mode_msg+=$'\t'"KW_MUTT_DIR=${KW_MUTT_DIR}"$'\n'
repo_mode_msg+=$'\t'"KW_MUTT_DIR=${KW_MUTT_MESSAGES_DIR}"$'\n'
repo_mode_msg+=$'\t'"KW_MUTT_DIR=${KW_MUTT_HEADERS_DIR}"$'\n'
repo_mode_msg+=$'\t'"KW_MUTT_MAIL_DIR=${KW_MUTT_MAIL_DIR}"$'\n'
repo_mode_msg+=$'\t'"KW_DOC_DIR=${KW_DOC_DIR}"$'\n'
repo_mode_msg+=$'\t'"KW_ETC_DIR=${KW_ETC_DIR}"$'\n'
repo_mode_msg+=$'\t'"KW_LIB_DIR=${KW_LIB_DIR}"$'\n'
Expand Down Expand Up @@ -268,6 +278,13 @@ function kw()
patch_hub_main "$@"
)
;;
patch-track)
(
include "${KW_LIB_DIR}/patch_track.sh"

patch_track_main "$@"
)
;;
clear-cache)
include "${KW_LIB_DIR}/deploy.sh"

Expand Down
6 changes: 6 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ declare -r etcdir="${XDG_CONFIG_HOME:-"$HOME/.config"}/$app_name"
declare -r cachedir="${XDG_CACHE_HOME:-"$HOME/.cache/$app_name"}"
declare -r tracingdir="${datadir}/tracing"
declare -r dot_configs_dir="${datadir}/configs"
declare -r muttdir="${datadir}/mutt"
declare -r muttmaildir="${muttdir}/mail"

##
## Source code references
Expand Down Expand Up @@ -557,6 +559,10 @@ function synchronize_files()
mkdir -p "$datadir"
mkdir -p "$datadir/statistics"
mkdir -p "$datadir/configs"

mkdir -p "$muttdir"
mkdir -p "$muttmaildir"

if [[ -x "${databasedir}/migrate_legacy_data_20220101.sh" ]]; then
eval "${databasedir}/migrate_legacy_data_20220101.sh"
else
Expand Down
4 changes: 4 additions & 0 deletions src/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function init_main()
local mail_name='send_patch.config'
local notification_name='notification.config'
local remote_name='remote.config'
local patch_track_mutt_name='patch_track_mutt.config'
local config_file_template
local deploy_config_file_template
local remote_file_template
Expand Down Expand Up @@ -66,6 +67,7 @@ function init_main()
mail_config_file_template="${KW_ETC_DIR}/send_patch.config"
notification_config_file_template="${KW_ETC_DIR}/notification_template.config"
remote_file_template="${KW_ETC_DIR}/remote.config"
patch_track_mutt_config_file_template="${KW_ETC_DIR}/patch_track_mutt.config"

if [[ ! -f "$config_file_template" || ! -f "$build_config_file_template" ]]; then
complain "No such: ${config_file_template}"
Expand All @@ -80,6 +82,8 @@ function init_main()
cmd_manager "$flag" "cp ${mail_config_file_template} ${PWD}/${KW_DIR}/${mail_name}"
cmd_manager "$flag" "cp ${notification_config_file_template} ${PWD}/${KW_DIR}/${notification_name}"
cmd_manager "$flag" "cp ${remote_file_template} ${PWD}/${KW_DIR}/${remote_name}"
cmd_manager "$flag" "cp ${patch_track_mutt_config_file_template} ${PWD}/${KW_DIR}/${patch_track_mutt_name}"

cmd_manager "$flag" "sed --in-place --expression \"s/USERKW/${USER}/g\" -e '/^#?.*/d' ${PWD}/${KW_DIR}/${vm_name}"
cmd_manager "$flag" "sed --in-place --expression \"s,SOUNDPATH,${KW_SOUND_DIR},g\" -e '/^#?.*/d' ${PWD}/${KW_DIR}/${notification_name}"

Expand Down
17 changes: 17 additions & 0 deletions src/lib/kw_config_loader.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ DEPLOY_CONFIG_FILENAME='deploy.config'
VM_CONFIG_FILENAME='vm.config'
SEND_PATCH_CONFIG_FILENAME='send_patch.config'
SEND_PATCH_CONFIG_FILENAME='lore.config'
PATCH_TRACK_MUTT_CONFIG_FILENAME='patch_track_mutt.config'

KW_DIR='.kw'

# Basic targets
Expand Down Expand Up @@ -53,6 +55,11 @@ declare -gA lore_config
declare -gA lore_config_global
declare -gA lore_config_local

# Notification configuration
declare -gA patch_track_mutt_config
declare -gA patch_track_mutt_config_global
declare -gA patch_track_mutt_config_local

# Default target option from kworkflow.config
declare -gA deploy_target_opt=(['local']=2 ['remote']=3)

Expand Down Expand Up @@ -325,12 +332,16 @@ function load_configuration()
'lore')
target_array='lore_config'
;;
'patch_track_mutt')
target_array='patch_track_mutt_config'
;;
esac

target_array_global="${target_array}_global"
target_array_local="${target_array}_local"

target_config_file="${target_config}.config"

parse_configuration "${KW_ETC_DIR}/${target_config_file}" "$target_array" "$target_array_global"

# XDG_CONFIG_DIRS is a colon-separated list of directories for config
Expand Down Expand Up @@ -399,6 +410,11 @@ load_lore_config()
load_configuration 'lore'
}

load_patch_track_mutt_config()
{
load_configuration 'patch_track_mutt'
}

load_all_config()
{
load_notification_config
Expand All @@ -408,4 +424,5 @@ load_all_config()
load_send_patch_config
load_lore_config
load_vm_config
load_patch_track_mutt_config
}
Loading