Skip to content
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
35 changes: 35 additions & 0 deletions database/kwdb.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,32 @@ CREATE TABLE IF NOT EXISTS "command_label" (
PRIMARY KEY("id")
);

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

-- 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")
);

-- Table containing the association between a kw email group and it's contacts
CREATE TABLE IF NOT EXISTS "email_contact_group" (
"contact_id" INTEGER,
"group_id" INTEGER,
PRIMARY KEY ("contact_id", "group_id"),
FOREIGN KEY ("contact_id") REFERENCES "email_contact"("id") ON DELETE CASCADE,
FOREIGN KEY ("group_id") REFERENCES "email_group"("id") ON DELETE CASCADE
);

-- Table containing the possible exit status of an executed commmand
CREATE TABLE IF NOT EXISTS "status" (
"id" INTEGER NOT NULL UNIQUE,
Expand Down Expand Up @@ -237,4 +263,13 @@ CREATE TRIGGER IF NOT EXISTS "insert_statistics" INSTEAD OF INSERT ON "statistic
);
END;

CREATE TRIGGER IF NOT EXISTS "delete_contact_if_no_group"
AFTER DELETE ON "email_contact_group"
FOR EACH ROW
WHEN (SELECT COUNT(*) FROM "email_contact_group" WHERE "contact_id" = OLD.contact_id) = 0
BEGIN
DELETE FROM "email_contact" WHERE "id" = OLD.contact_id;
END;


COMMIT;
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-manage-contacts', 'kw-manage-contacts', 'create and manage email groups', ['João Guilherme Barbosa de Souza'], 1),
]


Expand Down
93 changes: 93 additions & 0 deletions documentation/man/features/kw-manage-contacts.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
=============================================
kw-manage-contacts - Manage groups of emails
=============================================

.. _manage-contacts-doc:

SYNOPSIS
========
| *kw manage-contacts* (-c | \--group-create) [<name>]
| *kw manage-contacts* (-r | \--group-remove) [<name>]
| *kw manage-contacts* \--group-rename "[<old_name>]:[<new_name>]"
| *kw manage-contacts* \--group-add "[<group_name>]:[<ctt1_name>] <[<ctt1_email>]>, ..."
| *kw manage-contacts* \--group-remove-email "[<group_name>]:[<ctt1_name>] <[<ctt1_email>]>, ..."
| *kw manage-contacts* \--group-show=[<group_name>]

DESCRIPTION
===========

The `kw manage-contacts` is an email group manager feature that provides a comprehensive
interface for managing email groups, streamlining the process of organizing and
maintaining contact lists. This feature allows users to:

- Create new email groups
- Delete existing email groups
- Add contacts to a group
- Remove contacts from a group
- Rename email groups
- View all groups
- View contacts within a specific group

By integrating with the `kw send-patches` feature, email group manager simplifies
the patch submission process by making it possible to send a patch directly to a
group of contacts. Furthermore, it also guarantees the possibility of saving a
group after sending a patch.

OPTIONS
=======
-c, \--group-create [<name>]:
Create a new group with the specified name. The group will be stored in the
email_group table, which contains the group ID, name, and creation date.

-r, \--group-remove [<name>]:
Remove an existing group with the specified name. This action deletes the
group from the email_group table and also removes the associated contacts
in the email_contact_group table.

\--group-rename "[<old_name>]:[<new_name>]":
Rename an existing group from old_name to new_name. The change will be reflected
in the email_group table.

\--group-add "[<group_name>]:[<ctt1_name>] <[<ctt1_email>]>, [<ctt2_name>] <[<ctt2_email>]>, ...":
Add contacts to an existing group. Contacts are stored in the email_contact
table and the association between contacts and groups is stored in the
email_contact_group table.

\--group-remove-email "[<group_name>]:[<ctt1_name>] <[<ctt1_email>]>, [<ctt2_name>] <[<ctt2_email>]>, ...":
Remove contacts from an existing group. This action updates the
email_contact_group table to reflect the removal.

\--group-show[=<group_name>]:
Show all existing groups or contacts of a specific group if group_name is
provided. Group information is retrieved from the email_group
table and contact information from the email_contact table.

EXAMPLES
========
To create a new group named "NewGroup"::

kw manage-contacts -c "NewGroup"

To remove an existing group named "OldGroup"::

kw manage-contacts -r "OldGroup"

To rename an existing group from "OldGroup" to "NewGroup"::

kw manage-contacts --group-rename "OldGroup"

To add contacts (John Doe and Jane Smith) to an existing group named "ExistingGroup"::

kw manage-contacts --group-add "ExistingGroup: John Doe john.doe@example.com, Jane Smith jane.smith@example.com"

To remove John Doe from an existing group named "ExistingGroup"::

kw manage-contacts --group-remove-email "ExistingGroup John Doe john.doe@example.com"

To display all existing email groups::

kw manage-contacts --group-show

To display contacts of a specific group named "ExistingGroup"::

kw manage-contacts --group-show=ExistingGroup
21 changes: 16 additions & 5 deletions documentation/man/features/kw-send-patch.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ kw send-patch - Send patches through mail

SYNOPSIS
========
| *kw send-patch* (-s | \--send) [\--simulate] [\--private] [\--rfc] [\--to='<recipient>,...'] [\--cc='<recipient>,...'] [<rev-range>...] [-v<version>] [\-- <extra-args>...]
| *kw send-patch* (-s | \--send) [\--simulate] [\--private] [\--rfc] [\--to='<recipient>,...'] [\--cc='<recipient>,...'] [\--to-groups='<recipient>,...'] [\--cc-groups='<recipient>,...'] [<rev-range>...] [-v<version>] [\-- <extra-args>...]
| *kw send-patch* (-t | \--setup) [\--local | \--global] [-f | \--force] (<config> <value>)...
| *kw send-patch* (-i | \--interactive) [\--local | \--global]
| *kw send-patch* (-l | \--list)
Expand Down Expand Up @@ -44,10 +44,10 @@ OPTIONS
=======
-s, \--send:
Send a patch by email using ``git send-email`` to the email addresses
specified with ``--to`` and ``--cc``. You can provide *<extra-args>* to be
passed directly to ``git send-email``, they should be placed after the double
dash (``--``) argument. By default this function assumes these arguments to
``git send-email``::
specified with ``--to`` and ``--cc`` or the contacts group specified with ``to-groups``
and ``cc-groups``. You can provide *<extra-args>* to be passed directly to
``git send-email``, they should be placed after the double dash (``--``) argument.
By default this function assumes these arguments to ``git send-email``::

--annotate --cover-letter --no-chain-reply-to --thread

Expand All @@ -63,6 +63,14 @@ OPTIONS
\--cc='<recipient>,...':
Specify the recipients that will receive a copy of the patch via e-mail.

\--to-groups='<recipient>,...':
Specify the groups recipients that contain the email of the users that
will receive the patch via e-mail. The *<recipiient>* list can be any
of the groups created using the ``kw manage-contacts`` feature.

\--cc-groups='<recipient>,...':
Specify the groups recipients that will receive a copy of the patch via e-mail.

\--simulate:
Do everything without actually sending the e-mail. This is similar to
``git send-email``'s ``--dry-run`` option.
Expand Down Expand Up @@ -140,6 +148,9 @@ To simulate sending the last commit as a patch just write::

kw send-patch --send --simulate --to=some@email.com

To simulate sending the last commit as a patch to a group you can use::
kw send-patch --send --simulate --to-groups=somegroup

Then when you are sure the command executed as expected, drop the
``--simulate`` argument to actually send the patch::

Expand Down
7 changes: 7 additions & 0 deletions kw
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,13 @@ function kw()
kworkflow_man "$@"
)
;;
manage-contacts)
(
include "${KW_LIB_DIR}/kw_manage_contacts.sh"

manage_contacts_main "$@"
)
;;
help | --help)
(
include "${KW_LIB_DIR}/help.sh"
Expand Down
1 change: 1 addition & 0 deletions src/help.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function kworkflow_help()
' backup - Save or restore kw data' \
' debug - Linux kernel debug utilities' \
' send-patch - Send patches via email' \
' manage-contacts - Manage email contact groups' \
' env - Handle kw envs' \
' patch-hub - Open Terminal UI to interact with patches from lore.kernel.org' \
' clear-cache - Clear files generated by kw' \
Expand Down
Loading