Skip to content

Commit 9c93ecb

Browse files
authored
Merge branch 'master' into enable_ocis_7.1
2 parents 1f81669 + a407c89 commit 9c93ecb

12 files changed

+408
-75
lines changed

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
**Table of Contents**
1010

1111
* [Antora Site Structure for Docs](#antora-site-structure-for-docs)
12+
* [Extensions](#extensions)
1213
* [Documentation Guidelines](#documentation-guidelines)
1314
* [Contributing to the Documentation](#contributing-to-the-documentation)
1415
* [Generating the Documentation](#generating-the-documentation)
@@ -23,6 +24,10 @@
2324

2425
Refer to the [Antora Site Structure for Docs](./docs/antora-site-structure.md) for more information.
2526

27+
## Extensions
28+
29+
The documentation intensively uses Antora/Asciidoc extensions. These extensions enrich the base functionality with additional and required capabilities. Read the [extensions](./docs/extensions.md) documentation for more information.
30+
2631
## Documentation Guidelines
2732

2833
Refer to the [Documentation Guidelines](./docs/doc-guidelines.md) for more information about backgrounds and processes.
@@ -33,15 +38,15 @@ To get started contributing to the documentation, please refer to the [Getting S
3338

3439
With regard to language and style issues, consult the [Style Guide](./docs/style-guide.md).
3540

36-
Note that the documentation provides a setting for the [IntelliJ AsciiDoc-Antora Plugin](https://intellij-asciidoc-plugin.ahus1.de) to preview a page using the css sourced from `doc.owncloud.com`.
41+
Note that the documentation provides a setting for the [IntelliJ AsciiDoc-Antora Plugin](https://intellij-asciidoc-plugin.ahus1.de) to preview a page using the css sourced from `doc.owncloud.com`. The file required containing the necessary configuration is `.asciidoctorconfig`.
3742

3843
## Generating the Documentation
3944

4045
**IMPORTANT**
41-
We recently have upgraded to `node 18.19.0`. In case you used a lower node version for your local doc repos, you must upgrade them **all**. See the link below for details.
46+
We use `node 18.19.0`. In case you used a lower node version for your local doc repos, you must upgrade them **all**. See the link below for details.
4247

4348
**IMPORTANT**
44-
We recently have upgraded to `Antora 3.1.10` and use npm instead of yarn. In case you used a lower Antora version for your local doc repos, you must upgrade them **all** by syncing them and running `npm install` in each doc repo.
49+
We use `Antora 3.1.10` and use npm instead of yarn. In case you used a lower Antora version for your local doc repos, you must upgrade them **all** by syncing them and running `npm install` in each doc repo.
4550

4651
To generate and view the documentation locally or planning major changes, refer to the [Building the Documentation guide](./docs/build-the-docs.md).
4752

@@ -64,7 +69,7 @@ The **ONLY** reason for doing a PR in a branch directly is, to fix an issue whic
6469
_only_ present in that particular branch! When creating a PR and it is necessary to backport,
6570
document in the PR to which branches a backport is needed.
6671

67-
When backporting, consider using the [backport script](https://doc.owncloud.com/server/developer_manual/general/backporting.html)
72+
When backporting, consider using the [backport script](./docs/getting-started.md#backporting)
6873
which eases life a lot and speeds up the process. It is also very beneficial when using the
6974
extended code provided, because a clear naming structure of the backport PR is generated automatically.
7075

@@ -81,4 +86,4 @@ Please refer to [Create a New Version Branch for Docs](./docs/new-version-branch
8186

8287
## HTML to PDF
8388

84-
At the moment, creating a pdf from a component via Antora is broken and will be fixed past updating to Antora 3. In the meanwhile a workaround is provided, see the [HTML to PDF](./docs/html-to-pdf.md) description.
89+
At the moment, creating a pdf is dropped from the build process but can be re-implemented if required.

bin/git_commands/backport.sh

Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
#!/bin/bash
2+
# version 2024.06.05
3+
# backport the given merge SHA to the branch provided
4+
5+
if ! [ -x "$(command -v jq)" ]; then
6+
echo
7+
echo 'Error: jq is not installed.' >&2
8+
echo 'Please install package "jq" before using this script'
9+
echo
10+
exit 1
11+
fi
12+
13+
if ! [ -x "$(command -v curl)" ]; then
14+
echo
15+
echo 'Error: curl is not installed.' >&2
16+
echo 'Please install package "curl" before using this script'
17+
echo
18+
exit 1
19+
fi
20+
21+
if [ "$#" -lt 2 ]; then
22+
echo
23+
echo "Illegal number of parameters"
24+
echo " $0 <merge/commit-sha> <targetBranchName>"
25+
echo " For example: $0 1234567 10.8"
26+
echo
27+
exit 1
28+
fi
29+
30+
commit=$1
31+
targetBranch=$2
32+
sourceBranch=$(git rev-parse --abbrev-ref HEAD)
33+
34+
# check if the target branch exists on remote to avoid backporting to a non existing remote branch
35+
exists_in_remote=$(git ls-remote --heads origin ${targetBranch})
36+
if [ -z "${exists_in_remote}" ]; then
37+
echo
38+
echo "Branch ${targetBranch} does not exist on remote. Create it first. Exiting"
39+
echo
40+
exit 1
41+
fi
42+
43+
# check if the target branch already exists locally
44+
exists_in_local=$(git branch --list ${targetBranch})
45+
if [ -z "${exists_in_local}" ]; then
46+
echo
47+
echo "Branch ${targetBranch} does not exist locally. Make it available first. Exiting"
48+
echo
49+
exit 1
50+
fi
51+
52+
# check if the given merge commit exists in the actual checked out branch
53+
is_merged=$(git branch --contains $1 2>/dev/null | grep -oP '(?<=\*).*')
54+
if [ -z "${is_merged}" ]; then
55+
echo
56+
echo "${commit} does not exist because:"
57+
echo "- the PR has not been merged yet or"
58+
echo "- your actual backporting base branch ${sourceBranch} is not pulled/rebased."
59+
echo "Exiting"
60+
echo
61+
exit 1
62+
fi
63+
64+
# get the PR number from the merge commit
65+
# there can be a PR reference text in the commit like "fixes #1234".
66+
# we only need to take the last line which is then the real PR # the commit belongs to
67+
pullId=$(git log $1^! --oneline 2>/dev/null | tail -n 3 | grep -oP '(?<=#)[0-9]*' | tail -n 1)
68+
69+
# get the repository from the given commit
70+
# remove prefix and suffix from the full url returned
71+
repository=$(git config --get remote.origin.url 2>/dev/null)
72+
repository=${repository#"https://github.com/"}
73+
repository=${repository%".git"}
74+
75+
# get the list of commits in PR without any merge commit
76+
# $1^ means the first parent of the merge commit (that is passed in as $1).
77+
# because $1 is a "magically-generated" merge commit, it happily "jumps back"
78+
# to the point on the main branch just before where the PR was merged.
79+
# the commits from that point are exactly the list of individual
80+
# commits in the original PR.
81+
# --no-merges leaves out the merge commit itself, and we get just what we want
82+
commitList=$(git log --no-merges --reverse --format=format:%h $1^..$1)
83+
84+
# get the request reset time window from github in epoch
85+
rateLimitReset=$(curl -iks https://api.github.com/users/zen 2>&1 | grep -im1 'X-Ratelimit-Reset:' | grep -o '[[:digit:]]*')
86+
87+
# get the remaining requests in window from github
88+
rateLimitRemaining=$(curl -iks https://api.github.com/users/zen 2>&1 | grep -im1 'X-Ratelimit-Remaining:' | grep -o '[[:digit:]]*')
89+
90+
# time remaining in epoch
91+
now=$(date +%s)
92+
((remaining=rateLimitReset-now))
93+
94+
# time remaining in HMS
95+
remaining=$(date -u -d @${remaining} +%H:%M:%S)
96+
97+
# echo one time for a good rendering
98+
echo
99+
100+
# check if there are commits to cherry pick and list them if present
101+
if [[ -z "${commitList}" ]]; then
102+
echo "There are no commit(s) to cherry pick. Exiting"
103+
echo
104+
exit 1
105+
else
106+
lineCount=$(echo "${commitList}" | grep '' | wc -l)
107+
echo "${lineCount} commit(s) to be cherry picked:"
108+
echo
109+
echo "${commitList}"
110+
echo
111+
fi
112+
113+
if [ ${rateLimitRemaining} -le 0 ]; then
114+
# do not continue if there are no remaining github requests available
115+
echo
116+
echo "You do not have enough github requests available to backport"
117+
echo "The current rate limit window resets in ${remaining}"
118+
echo
119+
exit 1
120+
else
121+
# get the PR title, this is the only automated valid way to get the title
122+
pullTitle=$(curl https://api.github.com/repos/"${repository}"/pulls/"${pullId}" 2>/dev/null | jq '.title' | sed 's/^.//' | sed 's/.$//')
123+
# remove possible line breaks on any location in the string
124+
pullTitle=${pullTitle//$'\n'/}
125+
fi
126+
127+
# build variables for later use
128+
newBranch="${targetBranch}-${commit}-${pullId}"
129+
message="[${targetBranch}] [PR ${pullId}] ${pullTitle}"
130+
131+
# first check, if the source branch is clean and has no uncommited changes
132+
# in case this is true, checkout does not succeed and nothing needs to be done/switched
133+
# xargs removes any possible leading and trailing whitespaces
134+
is_source_branch_clean=$(git status --porcelain=v1 2>/dev/null | xargs)
135+
if [[ ! -z "${is_source_branch_clean}" ]]; then
136+
echo "Source branch ${sourceBranch} has probably uncommitted changes. Aborting."
137+
echo
138+
exit 1
139+
fi
140+
141+
# exit the script if any statement returns a non-true return value
142+
# means that all commands from now on must run successfully
143+
set -e
144+
145+
# fetch branches and/or tags from one or more other repositories, along with the
146+
# objects necessary to complete their histories
147+
git fetch -p --quiet
148+
149+
# checkout and rebase the target branch
150+
git checkout "${targetBranch}" --quiet
151+
152+
# if everything is ok, then rebase the target branch
153+
git pull --rebase --quiet
154+
155+
# create a new branch based on the target branch
156+
# the new branch name equals the new commit name
157+
git checkout -b "${newBranch}" "${targetBranch}"
158+
159+
echo
160+
161+
# cherry pick all commits from commitList
162+
lC=1
163+
echo "${commitList}" | while IFS= read -r line; do
164+
# start cherry-picking
165+
echo "Cherry picking commit ${lC}: ${line}"
166+
167+
# check if the commit to be cherry picked is already in the branch
168+
# this only works if the commit was cherry picked before!
169+
# else it will just try and continue.
170+
is_cherry_picked=$(git log --grep "${line}" 2>/dev/null)
171+
if [[ ! -z "${is_cherry_picked}" ]]; then
172+
echo
173+
echo "Commit ${line} has already been cherry picked, abort backporting."
174+
# go back to the base branch and delete the new branch with all its contents.
175+
git checkout --quiet "${sourceBranch}"
176+
git branch -D --quiet "${newBranch}"
177+
echo
178+
exit 1
179+
fi
180+
181+
# pull this commit into the new branch
182+
# --allow-empty is required if an empty commit is present like when when retriggering the CI.
183+
# if you do not want to use a default conflict resolution to take theirs
184+
# (help fix missing cherry picked commits or file renames)
185+
#git cherry-pick --allow-empty ${line} > /dev/null
186+
git cherry-pick --allow-empty -Xtheirs "${line}" > /dev/null
187+
lC=$(( ${lC} + 1 ))
188+
done
189+
190+
echo
191+
echo "Committing changes"
192+
echo
193+
194+
## rewrite the most recent commit message
195+
## the first -m creates the PR headline text
196+
## the second -m creates the PR message text
197+
git commit --allow-empty --quiet --amend -m "${message}" -m "Backport of PR #${pullId}"
198+
199+
echo "Pushing: ${message}"
200+
echo
201+
202+
git push --quiet -u origin "${newBranch}"
203+
git checkout --quiet "${sourceBranch}"
204+
205+
# open the browser and prepare the pull request
206+
echo
207+
sleep 4
208+
echo "Creating pull request for branch ${targetBranch} in ${repository}"
209+
xdg-open "https://github.com/${repository}/pull/new/${targetBranch}...${newBranch}" &>/dev/null

bin/git_commands/getcommits.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
echo "count branch commits compared against master or the branch name if provided"
4+
git rev-list --count HEAD ^"${1:-master}"

bin/git_commands/getpull.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/sh
2+
3+
# try to identify the pull request that was created for the commit ID provided
4+
5+
if [ -z "$1" ]; then
6+
echo "Usage: git getpull <SHA>"
7+
exit 1
8+
elif [ -z "$(git rev-parse --git-dir 2>/dev/null)" ]; then
9+
echo "Not in a git directory"
10+
exit 1
11+
else
12+
repository_path=$(git config --get remote.origin.url 2>/dev/null | perl -lne 'print $1 if /(?:(?:https?:\/\/github.com\/)|:)(.*?).git/')
13+
pull_base_url=https://github.com/$repository_path/pull
14+
pull_id=$(git log $1^! --oneline 2>/dev/null | tail -n 3 | grep -oP '(?<=#)[0-9]*')
15+
# pull_id=$(git log $1..master --ancestry-path --merges --oneline 2>/dev/null | tail -n 1 | perl -nle 'print $1 if /#(\d+)/')
16+
17+
# if [ -n "$pull_id" ]; then
18+
echo "$pull_base_url/$pull_id"
19+
# else
20+
# echo "Sorry, couldn't find that pull"
21+
# exit 1
22+
# fi
23+
fi
24+

bin/git_commands/squash.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
# squash the number of commits to one with a defined commit message
3+
4+
#get number of commits to squash
5+
squashCount=$1
6+
7+
#get the commit message
8+
shift
9+
commitMsg=$@
10+
11+
#regular expression to verify that squash number is an integer
12+
regex='^[0-9]+$'
13+
14+
echo "---------------------------------"
15+
echo "Will squash $squashCount commits"
16+
echo "Commit message will be '$commitMsg'"
17+
18+
echo "...validating input"
19+
20+
if ! [[ $squashCount =~ $regex ]]
21+
then
22+
echo "Squash count must be an integer."
23+
elif [ -z "$commitMsg" ]
24+
then
25+
echo "Invalid commit message. Make sure string is not empty"
26+
else
27+
echo "...input looks good"
28+
echo "...proceeding to squash"
29+
git reset --soft HEAD~$squashCount
30+
git commit -m "$commitMsg"
31+
echo "...done"
32+
fi
33+
34+
35+
36+
echo
37+
38+
exit 0
39+

0 commit comments

Comments
 (0)