Skip to content

Commit

Permalink
Merge branch 'trunk' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
herrhotzenplotz committed Aug 11, 2023
2 parents 2503abe + f1b942e commit a6e295d
Show file tree
Hide file tree
Showing 35 changed files with 1,117 additions and 8 deletions.
7 changes: 7 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ gcli_LDADD = libgcli.la libpdjson.la libsn.la
dist_man_MANS = \
docs/gcli-api.1 \
docs/gcli-comment.1 \
docs/gcli-config.1 \
docs/gcli-forks.1 \
docs/gcli-gists.1 \
docs/gcli-issues.1 \
Expand All @@ -58,6 +59,7 @@ gcli_SOURCES = \
src/cmd/api.c \
src/cmd/ci.c \
src/cmd/comment.c \
src/cmd/config.c \
src/cmd/forks.c \
src/cmd/gists.c \
src/cmd/issues.c \
Expand Down Expand Up @@ -102,6 +104,7 @@ TEMPLATES = \
templates/gitlab/releases.t \
templates/gitlab/repos.t \
templates/gitlab/review.t \
templates/gitlab/sshkeys.t \
templates/gitlab/status.t \
templates/gitlab/snippets.t \
templates/gitea/milestones.t
Expand All @@ -125,6 +128,7 @@ libgcli_la_SOURCES = \
src/review.c include/gcli/review.h \
src/gitlab/snippets.c include/gcli/gitlab/snippets.h \
src/status.c include/gcli/status.h \
src/sshkeys.c include/gcli/sshkeys.h \
src/table.c include/gcli/table.h \
src/gitlab/api.c include/gcli/gitlab/api.h \
src/gitlab/comments.c include/gcli/gitlab/comments.h \
Expand All @@ -139,6 +143,7 @@ libgcli_la_SOURCES = \
src/gitlab/repos.c include/gcli/gitlab/repos.h \
src/gitlab/review.c include/gcli/gitlab/review.h \
src/gitlab/status.c include/gcli/gitlab/status.h \
src/gitlab/sshkeys.c include/gcli/gitlab/sshkeys.h \
src/github/releases.c include/gcli/github/releases.h \
src/github/config.c include/gcli/github/config.h \
src/github/api.c include/gcli/github/api.h \
Expand All @@ -153,6 +158,7 @@ libgcli_la_SOURCES = \
src/github/review.c include/gcli/github/review.h \
src/github/checks.c include/gcli/github/checks.h \
src/github/gists.c include/gcli/github/gists.h \
src/github/sshkeys.c include/gcli/github/sshkeys.h \
src/gitea/issues.c include/gcli/gitea/issues.h \
src/gitea/labels.c include/gcli/gitea/labels.h \
src/gitea/forks.c include/gcli/gitea/forks.h \
Expand All @@ -161,6 +167,7 @@ libgcli_la_SOURCES = \
src/gitea/pulls.c include/gcli/gitea/pulls.h \
src/gitea/releases.c include/gcli/gitea/releases.h \
src/gitea/repos.c include/gcli/gitea/repos.h \
src/gitea/sshkeys.c include/gcli/gitea/sshkeys.h \
src/gitea/milestones.c include/gcli/gitea/milestones.h \
$(TEMPLATES)

Expand Down
5 changes: 3 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.69])
AC_INIT([gcli],[1.1.0],[[email protected]],[gcli],[https://gitlab.com/herrhotzenplotz/gcli/])
AC_INIT([gcli],[1.2.0],[[email protected]],[gcli],[https://gitlab.com/herrhotzenplotz/gcli/])
AM_INIT_AUTOMAKE([1.0 foreign subdir-objects dist-bzip2 dist-xz -Wall])

dnl Release Date.
Expand Down Expand Up @@ -38,7 +38,7 @@ OPT_LIBCURL=$withval

AS_IF([test "x$OPT_LIBCURL" = "xno"],
[AC_MSG_ERROR([--with-libcurl must not be disabled])])
AS_IF([test "x$OPT_LIBCURL" = "xcheck"],
AS_IF([test "x$OPT_LIBCURL" = "xcheck" || test "x$OPT_LIBCURL" = "xyes"],
[PKG_CHECK_MODULES([LIBCURL], [libcurl],,[AC_MSG_ERROR([Could not find libcurl])])
CFLAGS="$LIBCURL_CFLAGS $CFLAGS"
LDFLAGS="$LIBCURL_LIBS $LDFLAGS"],
Expand All @@ -64,6 +64,7 @@ dnl Generate and substitute various files
AC_CONFIG_FILES([Makefile
docs/gcli-api.1
docs/gcli-comment.1
docs/gcli-config.1
docs/gcli-forks.1
docs/gcli-gists.1
docs/gcli-issues.1
Expand Down
67 changes: 67 additions & 0 deletions docs/gcli-config.1.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
.Dd @PACKAGE_DATE@
.Dt GCLI-ISSUES 1
.Os @PACKAGE_STRING@
.Sh NAME
.Nm gcli config
.Nd Git Forge Configuration
.Sh SYNOPSIS
.Nm
.Cm ssh
.Nm
.Cm ssh add
.Fl t Ar title
.Fl k Ar keypath
.Nm
.Cm ssh delete
.Fl i Ar id
.Sh DESCRIPTION
.Nm
is used to change the settings of the Git Forge Account. You can use
it to e.g. add or delete SSH Public Keys used to push to forges.
.Sh OPTIONS
.Bl -tag -width xxxxxxxxxxxxxxxxx
.It Fl t , -title Ar title
Set the title of the SSH Key to be added. This is a short description
of the key.
.It Fl k , -key Pa keypath
Path to the file containing the SSH public key.
.It Fl i , -id Ar id
ID of the public key to delete.
.El
.
.Sh SUBCOMMANDS
.Bl -tag -width xxxxxxxxxxx
.It Cm ssh
List SSH public keys for the current user.
.It Cm ssh add
Add a SSH public key for the current user.
.It Cm ssh delete
Delete a SSH public key for the current user.
.El
.Sh EXAMPLES
Print a list of registered SSH public keys:
.Bd -literal -offset indent
$ gcli config ssh
.Ed
.Pp
Register ~/.ssh/id_rsa.pub on the default forge:
.Bd -literal -offset indent
$ gcli config ssh add \\
-t "Key for $(hostname)" \\
-k ~/.ssh/id_rsa.pub
.Ed
.Pp
.Sh SEE ALSO
.Xr git 1 ,
.Xr gcli 1
.Sh AUTHORS
.An Nico Sonack aka. herrhotzenplotz Aq Mt [email protected]
and contributors.
.Sh BUGS
When using this feature to manage SSH keys on Github be aware that you need the
.Dq read:public_key
scope enabled on your access token. You will receive HTTP 404 errors
otherwise.
.Pp
Please report bugs at @PACKAGE_URL@, via E-Mail to @PACKAGE_BUGREPORT@
or on Github.
6 changes: 6 additions & 0 deletions docs/gcli-issues.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ Remove the given label from the issue.
.It Cm milestone Ar id
Assign the issue to a milestone with the given
.Ar id .
.It Cm milestone Fl d
Clear associated milestone of the given issue.
.It Cm notes
Alias for the
.Cm comments
action that prints the list of comments associated with the issue.
.El
.Sh EXAMPLES
Print a list of issues in the current project:
Expand Down
9 changes: 9 additions & 0 deletions docs/gcli-pulls.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,15 @@ Squash the commits before merging.
.It Fl -inhibit-delete , D
Delete the source branch after merging.
.El
.It Cm milestone Ar milestone-id
Assign the pull request to the given
.Ar milestone-id .
.It Cm milestone Fl d
Clear a set milestone on the pull request.
.It Cm notes
Alias for the
.Cm comments
action that prints a list of comments associated with the PR.
.It Cm reviews
Print reviews including comments under them.
.It Cm labels Op Ar options
Expand Down
5 changes: 5 additions & 0 deletions docs/gcli.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ Create and manage releases. See
.It Cm milestones
List and manage milestones. See
.Xr gcli-milestones 1 .
.It Cm config
Change user settings for the forge. Allows you to e.g. upload or
delete ssh keys. See
.Xr gcli-config 1 .
.It Cm api
Perform direct queries to the API and dump the JSON response to
stdout. This is primarily intended to assist debugging gcli. See
Expand Down Expand Up @@ -280,6 +284,7 @@ working from contain the relevant forge and repository information.
.Xr gcli-releases 1 ,
.Xr gcli-comment 1
.Xr gcli-pipelines 1
.Xr gcli-config 1
.Sh HISTORY
The idea for
.Nm
Expand Down
1 change: 1 addition & 0 deletions include/gcli/cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ void delete_repo(bool always_yes, const char *owner, const char *repo);
int subcommand_api(int argc, char *argv[]);
int subcommand_ci(int argc, char *argv[]);
int subcommand_comment(int argc, char *argv[]);
int subcommand_config(int argc, char *argv[]);
int subcommand_forks(int argc, char *argv[]);
int subcommand_gists(int argc, char *argv[]);
int subcommand_issues(int argc, char *argv[]);
Expand Down
30 changes: 30 additions & 0 deletions include/gcli/forges.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include <gcli/releases.h>
#include <gcli/repos.h>
#include <gcli/review.h>
#include <gcli/sshkeys.h>
#include <gcli/status.h>

typedef struct gcli_forge_descriptor gcli_forge_descriptor;
Expand Down Expand Up @@ -319,6 +320,21 @@ struct gcli_forge_descriptor {
char const *const labels[],
size_t labels_size);

/**
* Assign a PR to a milestone */
int (*pr_set_milestone)(
char const *owner,
char const *repo,
int pr,
int milestone_id);

/**
* Clear a milestone on a PR */
int (*pr_clear_milestone)(
char const *owner,
char const *repo,
int pr);

/**
* Get a list of releases in the given repo */
int (*get_releases)(
Expand Down Expand Up @@ -416,6 +432,20 @@ struct gcli_forge_descriptor {
* Get the user account name */
sn_sv (*get_account)(void);

/**
* Get list of SSH keys */
int (*get_sshkeys)(gcli_sshkey_list *);

/**
* Add an SSH public key */
int (*add_sshkey)(char const *title,
char const *public_key_path,
gcli_sshkey *out);

/**
* Delete an SSH public key by its ID */
int (*delete_sshkey)(int id);

/**
* Get the error string from the API */
char const *(*get_api_error_string)(
Expand Down
4 changes: 4 additions & 0 deletions include/gcli/gitea/issues.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,8 @@ int gitea_issue_set_milestone(char const *owner,
int issue,
int milestone);

int gitea_issue_clear_milestone(char const *owner,
char const *repo,
int issue);

#endif /* GITEA_ISSUES_H */
9 changes: 9 additions & 0 deletions include/gcli/gitea/pulls.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,13 @@ int gitea_pull_checks(char const *owner,
char const *repo,
int pr_number);

int gitea_pull_set_milestone(char const *owner,
char const *repo,
int pr_number,
int milestone_id);

int gitea_pull_clear_milestone(char const *owner,
char const *repo,
int pr_number);

#endif /* GITEA_PULLS_H */
41 changes: 41 additions & 0 deletions include/gcli/gitea/sshkeys.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright 2023 Nico Sonack <[email protected]>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef GCLI_GITEA_SSHKEYS_H
#define GCLI_GITEA_SSHKEYS_H

#include <gcli/sshkeys.h>

int gitea_get_sshkeys(gcli_sshkey_list *out);
int gitea_add_sshkey(char const *title,
char const *public_key_data,
gcli_sshkey *out);
int gitea_delete_sshkey(int id);

#endif /* GCLI_GITEA_SSHKEYS_H */
41 changes: 41 additions & 0 deletions include/gcli/github/sshkeys.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright 2023 Nico Sonack <[email protected]>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef GCLI_GITHUB_SSHKEYS_H
#define GCLI_GITHUB_SSHKEYS_H

#include <gcli/sshkeys.h>

int github_get_sshkeys(gcli_sshkey_list *out);
int github_add_sshkey(char const *const title,
char const *const pubkey,
gcli_sshkey *out);
int github_delete_sshkey(int id);

#endif /* GCLI_GITHUB_SSHKEYS_H */
9 changes: 9 additions & 0 deletions include/gcli/gitlab/merge_requests.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,13 @@ void gitlab_mr_remove_labels(char const *owner,
char const *const labels[],
size_t labels_size);

int gitlab_mr_set_milestone(char const *owner,
char const *repo,
int mr,
int milestone_id);

int gitlab_mr_clear_milestone(char const *owner,
char const *repo,
int mr);

#endif /* GITLAB_MERGE_REQUESTS_H */
Loading

0 comments on commit a6e295d

Please sign in to comment.