Skip to content

Commit

Permalink
Add GitLab support
Browse files Browse the repository at this point in the history
  • Loading branch information
PawelLipski committed Mar 15, 2024
1 parent 4a3f9ae commit 68538de
Show file tree
Hide file tree
Showing 25 changed files with 899 additions and 472 deletions.
5 changes: 5 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Release notes

## New in git-machete 3.25.0

- added: GitLab support via `git machete gitlab` (first suggested by @mikeynap, partly contributed by @max-nicholson)
- added: `git machete anno --sync-gitlab-prs` flag for consistency

## New in git-machete 3.24.3

- added: Scoop package for Windows (suggested by @ppasieka)
Expand Down
11 changes: 11 additions & 0 deletions ci/checks/enforce-consistent-style-for-gitlab.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

set -e -o pipefail -u

self_dir=$(cd "$(dirname "$0")" &>/dev/null; pwd -P)
source "$self_dir"/utils.sh
self_name=$(basename "$0")

if git grep -n Gitlab -- :!**/$self_name; then
die "Please use 'GitLab' instead of 'Gitlab'."
fi
2 changes: 1 addition & 1 deletion ci/checks/enforce-mocking-only-whitelisted-methods.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ whitelisted_methods="\
builtins.input
builtins.open
git_machete.client.MacheteClient.is_stdout_a_tty
git_machete.code_hosting.OrganizationAndRepository.from_url
git_machete.git_operations.GitContext.fetch_remote
git_machete.github.GitHubClient.MAX_PULLS_PER_PAGE_COUNT
git_machete.github.GitHubToken.for_domain
git_machete.github.OrganizationAndRepository.from_url
git_machete.utils._popen_cmd
git_machete.utils._run_cmd
git_machete.utils.find_executable
Expand Down
1 change: 1 addition & 0 deletions ci/checks/run-all-checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ set -e -x
enforce-bumped-version.sh
enforce-consistent-style-for-fork-point.sh
enforce-consistent-style-for-github.sh
enforce-consistent-style-for-gitlab.sh
enforce-correct-shebangs.sh
enforce-indent-two-spaces-outside-python.sh
enforce-issue-number-for-todos.sh
Expand Down
26 changes: 15 additions & 11 deletions docs/man/git-machete.1
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
.TH "GIT-MACHETE" "1" "Mar 11, 2024" "" "git-machete"
.TH "GIT-MACHETE" "1" "Mar 15, 2024" "" "git-machete"
.SH NAME
git-machete \- git-machete 3.24.3
git-machete \- git-machete 3.25.0
.sp
git machete is a robust tool that \fBsimplifies your git workflows\fP\&.
.sp
Expand Down Expand Up @@ -260,6 +260,7 @@ Fails if the current branch has more than one green\-edge downstream branch.
.ft C
git machete anno [\-b|\-\-branch=<branch>] [<annotation text>]
git machete anno \-H|\-\-sync\-github\-prs
git machete anno \-\-sync\-gitlab\-prs
.ft P
.fi
.UNINDENT
Expand All @@ -282,10 +283,12 @@ $ git machete anno \(aq\(aq
.sp
then clears the annotation for the current branch (or a branch specified with \fB\-b/\-\-branch\fP).
.sp
If invoked with \fB\-H\fP or \fB\-\-sync\-github\-prs\fP, annotates the branches based on their corresponding GitHub PR numbers and authors.
When the current user is NOT the owner of the PR associated with that branch, adds \fBrebase=no push=no\fP branch qualifiers used by \fBgit machete traverse\fP,
so that you don\(aqt rebase or push someone else\(aqs PR by accident (see help for \fI\%traverse\fP).
Any existing annotations (except branch qualifiers) are overwritten for the branches that have an opened PR; annotations for the other branches remain untouched.
If invoked with \fB\-H\fP or \fB\-\-sync\-github\-prs\fP (for GitHub) or \fB\-\-sync\-gitlab\-prs\fP (for GitLab),
annotates the branches based on their corresponding GitHub PR/GitLab MR numbers and authors.
When the current user is NOT the author of the PR/MR associated with that branch, adds \fBrebase=no push=no\fP branch qualifiers used by \fBgit machete traverse\fP,
so that you don\(aqt rebase or push someone else\(aqs PR/MR by accident (see help for \fI\%traverse\fP).
Any existing annotations (except branch qualifiers) are overwritten for the branches that have an opened PR/MR;
annotations for the other branches remain untouched.
.sp
\fBNOTE:\fP
.INDENT 0.0
Expand Down Expand Up @@ -375,7 +378,7 @@ Note: all the effects of \fBanno\fP can be always achieved by manually editing t
Branch to set the annotation for.
.TP
.B \-H\fP,\fB \-\-sync\-github\-prs
Annotate with GitHub PR numbers and authors where applicable.
Annotate with GitHub PR/GitLab MR numbers and authors where applicable.
.UNINDENT
.sp
\fBEnvironment variables:\fP
Expand Down Expand Up @@ -1063,7 +1066,7 @@ Annotates the branches based on their corresponding GitHub PR numbers and author
Any existing annotations are overwritten for the branches that have an opened PR; annotations for the other branches remain untouched.
Equivalent to \fBgit machete anno \-\-sync\-github\-prs\fP\&.
.sp
When the current user is NOT the owner of the PR associated with that branch, adds \fBrebase=no push=no\fP branch qualifiers used by \fBgit machete traverse\fP,
When the current user is NOT the author of the PR associated with that branch, adds \fBrebase=no push=no\fP branch qualifiers used by \fBgit machete traverse\fP,
so that you don\(aqt rebase or push someone else\(aqs PR by accident (see help for \fI\%traverse\fP).
.sp
\fBOptions:\fP
Expand All @@ -1079,7 +1082,7 @@ also traverse chain of pull requests upwards, adding branches one by one to git\
Once the specified pull requests are checked out locally, annotate local branches with corresponding pull request numbers.
If only one PR has been checked out, then switch the local repository\(aqs HEAD to its head branch.
.sp
When the current user is NOT the owner of the PR associated with that branch, adds \fBrebase=no push=no\fP branch qualifiers used by \fBgit machete traverse\fP,
When the current user is NOT the author of the PR associated with that branch, adds \fBrebase=no push=no\fP branch qualifiers used by \fBgit machete traverse\fP,
so that you don\(aqt rebase or push someone else\(aqs PR by accident (see help for \fI\%traverse\fP).
.sp
\fBOptions:\fP
Expand Down Expand Up @@ -1941,8 +1944,9 @@ master
.UNINDENT
.UNINDENT
.sp
Operations like \fBgit machete github anno\-prs\fP and \fBgit machete github checkout\-prs\fP add \fBrebase=no push=no\fP branch qualifiers
when the current user is NOT the owner of the PR associated with that branch.
Operations like \fBgit machete github anno\-prs\fP (\fBgit machete gitlab anno\-mrs\fP)
and \fBgit machete github checkout\-prs\fP (\fBgit machete gitlab checkout\-mrs\fP) add \fBrebase=no push=no\fP branch qualifiers
when the current user is NOT the author of the PR/MR associated with that branch.
.sp
\fBOptions:\fP
.INDENT 0.0
Expand Down
13 changes: 8 additions & 5 deletions docs/source/cli/anno.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ anno
git machete anno [-b|--branch=<branch>] [<annotation text>]
git machete anno -H|--sync-github-prs
git machete anno --sync-gitlab-prs
If invoked without any <annotation text>, prints out the custom annotation for the given branch
(or current branch, if none specified with ``-b/--branch``).
Expand All @@ -20,10 +21,12 @@ If invoked with a single empty string <annotation text>, like:
then clears the annotation for the current branch (or a branch specified with ``-b/--branch``).

If invoked with ``-H`` or ``--sync-github-prs``, annotates the branches based on their corresponding GitHub PR numbers and authors.
When the current user is NOT the owner of the PR associated with that branch, adds ``rebase=no push=no`` branch qualifiers used by ``git machete traverse``,
so that you don't rebase or push someone else's PR by accident (see help for :ref:`traverse`).
Any existing annotations (except branch qualifiers) are overwritten for the branches that have an opened PR; annotations for the other branches remain untouched.
If invoked with ``-H`` or ``--sync-github-prs`` (for GitHub) or ``--sync-gitlab-prs`` (for GitLab),
annotates the branches based on their corresponding GitHub PR/GitLab MR numbers and authors.
When the current user is NOT the author of the PR/MR associated with that branch, adds ``rebase=no push=no`` branch qualifiers used by ``git machete traverse``,
so that you don't rebase or push someone else's PR/MR by accident (see help for :ref:`traverse`).
Any existing annotations (except branch qualifiers) are overwritten for the branches that have an opened PR/MR;
annotations for the other branches remain untouched.

.. include:: github_api_access.rst
.. include:: github_access_config_keys.rst
Expand All @@ -39,7 +42,7 @@ Note: all the effects of ``anno`` can be always achieved by manually editing the

-b, --branch=<branch> Branch to set the annotation for.

-H, --sync-github-prs Annotate with GitHub PR numbers and authors where applicable.
-H, --sync-github-prs Annotate with GitHub PR/GitLab MR numbers and authors where applicable.

**Environment variables:**

Expand Down
4 changes: 2 additions & 2 deletions docs/source/cli/github.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Creates, checks out and manages GitHub PRs while keeping them reflected in branc
Any existing annotations are overwritten for the branches that have an opened PR; annotations for the other branches remain untouched.
Equivalent to ``git machete anno --sync-github-prs``.

When the current user is NOT the owner of the PR associated with that branch, adds ``rebase=no push=no`` branch qualifiers used by ``git machete traverse``,
When the current user is NOT the author of the PR associated with that branch, adds ``rebase=no push=no`` branch qualifiers used by ``git machete traverse``,
so that you don't rebase or push someone else's PR by accident (see help for :ref:`traverse`).

**Options:**
Expand All @@ -38,7 +38,7 @@ Creates, checks out and manages GitHub PRs while keeping them reflected in branc
Once the specified pull requests are checked out locally, annotate local branches with corresponding pull request numbers.
If only one PR has been checked out, then switch the local repository's HEAD to its head branch.

When the current user is NOT the owner of the PR associated with that branch, adds ``rebase=no push=no`` branch qualifiers used by ``git machete traverse``,
When the current user is NOT the author of the PR associated with that branch, adds ``rebase=no push=no`` branch qualifiers used by ``git machete traverse``,
so that you don't rebase or push someone else's PR by accident (see help for :ref:`traverse`).

**Options:**
Expand Down
5 changes: 3 additions & 2 deletions docs/source/cli/traverse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ Example machete file with branch qualifiers:
someone-elses-branch PR #124 rebase=no push=no
branch-for-local-experiments push=no
Operations like ``git machete github anno-prs`` and ``git machete github checkout-prs`` add ``rebase=no push=no`` branch qualifiers
when the current user is NOT the owner of the PR associated with that branch.
Operations like ``git machete github anno-prs`` (``git machete gitlab anno-mrs``)
and ``git machete github checkout-prs`` (``git machete gitlab checkout-mrs``) add ``rebase=no push=no`` branch qualifiers
when the current user is NOT the author of the PR/MR associated with that branch.


**Options:**
Expand Down
2 changes: 1 addition & 1 deletion git_machete/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '3.24.3'
__version__ = '3.25.0'
Loading

0 comments on commit 68538de

Please sign in to comment.