Skip to content

Commit 4169201

Browse files
authored
Merge pull request #95
* [TASK] Add issues templates. Add code of conduct file, add contributi… * [TASK] Refactor "ddev next" command.
1 parent fc2b122 commit 4169201

File tree

10 files changed

+520
-372
lines changed

10 files changed

+520
-372
lines changed

.ddev/commands/web/next

+73-18
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,93 @@
44
## Usage: next
55
## Example: "ddev next, ddev next patch, ddev next minor, ddev next major"
66

7-
INCREASE_PATCH="patch"
8-
INCREASE_MINOR="minor"
9-
INCREASE_MAJOR="major"
7+
DEFAULT_BRANCH=$(git remote show origin | grep 'HEAD branch' | cut -d' ' -f5)
108

11-
versionType=${1:-$INCREASE_PATCH}
9+
# Ensure DEFAULT_BRANCH is set
10+
if [ -z "$DEFAULT_BRANCH" ]; then
11+
echo "Error: DEFAULT_BRANCH could not be determined."
12+
exit 1
13+
fi
1214

13-
IFS='.' read -ra lastTagParts <<< "$(git tag -l --sort=v:refname | tail -1)"
15+
# Check if on '${DEFAULT_BRANCH}' branch
16+
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
17+
if [ "$CURRENT_BRANCH" != "$DEFAULT_BRANCH" ]; then
18+
echo "You are on branch '$CURRENT_BRANCH'. Before tagging please switch to the '$DEFAULT_BRANCH' branch and make sure it's up to date by running 'git pull'. Then run 'ddev next' command again."
19+
exit 1
20+
fi
21+
22+
# Fetch the latest state of the remote branch
23+
if ! git fetch -q origin $DEFAULT_BRANCH; then
24+
echo "Error: Failed to fetch from origin. Please check your network connection and remote repository configuration."
25+
exit 1
26+
fi
27+
28+
# Check if the local branch is behind the remote branch
29+
LOCAL=$(git rev-parse @)
30+
REMOTE=$(git rev-parse @{u})
31+
BASE=$(git merge-base @ @{u})
32+
33+
if [ "$LOCAL" != "$REMOTE" ]; then
34+
if [ "$LOCAL" == "$BASE" ]; then
35+
echo "Your local '$DEFAULT_BRANCH' branch is behind the remote. Please update it with 'git pull' and run 'ddev next' command again."
36+
exit 1
37+
elif [ "$REMOTE" == "$BASE" ]; then
38+
echo "Your local '$DEFAULT_BRANCH' branch has commits that are not pushed to the remote. Please push your changes with 'git push' and run 'ddev next' command again."
39+
exit 1
40+
else
41+
echo "Your local '$DEFAULT_BRANCH' branch has diverged from the remote. Please resolve the divergence before proceeding."
42+
exit 1
43+
fi
44+
fi
45+
46+
47+
versionType=${1:-patch}
48+
if [ ! -z "$versionType" ]; then
49+
if [ "$versionType" != "patch" ] && [ "$versionType" != "minor" ] && [ "$versionType" != "major" ]; then
50+
echo "Error: Invalid argument. Please use 'patch', 'minor', or 'major'."
51+
exit 1
52+
fi
53+
fi
54+
55+
# Validate and increment version
56+
lastTag=$(git tag -l --sort=v:refname | tail -1)
57+
if ! [[ $lastTag =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
58+
echo "Error: Last tag '$lastTag' does not follow semantic versioning."
59+
exit 1
60+
fi
61+
62+
IFS='.' read -ra lastTagParts <<< "$lastTag"
1463
major=${lastTagParts[0]}
1564
minor=${lastTagParts[1]}
1665
patch=${lastTagParts[2]}
1766

1867
case $versionType in
19-
$INCREASE_MINOR)
68+
major)
69+
((major++))
70+
minor=0
2071
patch=0
21-
minor=$((minor+1))
2272
;;
23-
$INCREASE_MAJOR)
73+
minor)
74+
((minor++))
2475
patch=0
25-
minor=0
26-
major=$((major+1))
2776
;;
28-
$INCREASE_PATCH)
29-
patch=$((patch+1))
77+
patch)
78+
((patch++))
3079
;;
3180
esac
3281

33-
nextTag="$major.$minor.$patch"
82+
NEXT_TAG="$major.$minor.$patch"
3483

35-
sed -i "s/'version' => '[0-9]\+\.[0-9]\+\.[0-9]\+'/'version' => '$nextTag'/g" ./ext_emconf.php
84+
if git rev-parse "$NEXT_TAG" >/dev/null 2>&1; then
85+
echo "Error: Tag '$NEXT_TAG' already exists. Please check the current version."
86+
exit 1
87+
fi
3688

37-
sed -i "s/release=\"[0-9]\+\.[0-9]\+\.[0-9]\+\"/release=\"$nextTag\"/g" ./Documentation/guides.xml
38-
sed -i'' -E "s/(<project[^>]* version=\")[^\"]+(\")/\1$nextTag\2/" ./Documentation/guides.xml
89+
# Update files with the new version
90+
sed -i "s/'version' => '[0-9]\+\.[0-9]\+\.[0-9]\+'/'version' => '$NEXT_TAG'/g" ./ext_emconf.php
91+
sed -i "s/release=\"[0-9]\+\.[0-9]\+\.[0-9]\+\"/release=\"$NEXT_TAG\"/g" ./Documentation/guides.xml
92+
sed -i'' -E "s/(<project[^>]* version=\")[^\"]+(\")/\1$NEXT_TAG\2/" ./Documentation/guides.xml
3993

40-
default_branch=$(git remote show origin | grep 'HEAD branch' | cut -d' ' -f5)
41-
echo "git add Documentation/guides.xml ext_emconf.php && git commit -m 'Tag new version' && git tag -a '$nextTag' -m '$nextTag' -s && git push origin $default_branch --tags"
94+
# Prepare command to tag the new version
95+
echo "Copy the command below and run it to tag the new version:"
96+
echo "git add Documentation/guides.xml ext_emconf.php && git commit -m 'Tag version $NEXT_TAG' && git tag -a '$NEXT_TAG' -m 'Version $NEXT_TAG' -s && git push origin $DEFAULT_BRANCH --tags"

.github/ISSUE_TEMPLATE/bug_report.yml

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Bug report
2+
description: Create a report to help improve the extension.
3+
title: "[BUG]"
4+
labels:
5+
- bug
6+
assignees:
7+
- kszymukowicz
8+
body:
9+
- type: input
10+
id: typo3-version
11+
attributes:
12+
label: TYPO3 version
13+
description: What TYPO3 version are you using?
14+
placeholder: 'e.g. 12.4.2'
15+
validations:
16+
required: true
17+
- type: input
18+
id: php-version
19+
attributes:
20+
label: PHP version
21+
description: What PHP version are you using?
22+
placeholder: 'e.g. 8.3.23'
23+
validations:
24+
required: true
25+
- type: input
26+
id: extension-version
27+
attributes:
28+
label: Extension version
29+
description: What version of EXT:t3api are you using?
30+
placeholder: 'e.g. 3.0.1'
31+
validations:
32+
required: true
33+
- type: checkboxes
34+
id: composer-mode
35+
attributes:
36+
label: Composer mode
37+
description: Are you running TYPO3 in composer mode?
38+
options:
39+
- label: I'm running TYPO3 in composer mode.
40+
- type: input
41+
id: operating-system
42+
attributes:
43+
label: Operating system
44+
description: What operating system are you using?
45+
placeholder: 'e.g. macOS 14.5'
46+
validations:
47+
required: true
48+
- type: textarea
49+
attributes:
50+
label: Current behavior
51+
description: A clear description of what the bug is.
52+
- type: textarea
53+
attributes:
54+
label: Expected behavior
55+
description: A clear description of what you expected to happen.
56+
- type: textarea
57+
attributes:
58+
label: Steps to reproduce
59+
description: If possible, describe steps to reproduce the behavior.
60+
placeholder: |
61+
1. [First Step]
62+
2. [Second Step]
63+
3. [and so on...]
64+
- type: textarea
65+
attributes:
66+
label: Additional context
67+
description: Add any other context about the problem here.
68+
- type: checkboxes
69+
id: terms
70+
attributes:
71+
label: Code of Conduct
72+
description: >
73+
By submitting this issue, you agree to follow our
74+
[Code of Conduct](https://github.com/sourcebroker/t3api/blob/main/CODE_OF_CONDUCT.md).
75+
options:
76+
- label: I agree to follow this project's Code of Conduct.
77+
required: true
78+
- type: markdown
79+
attributes:
80+
value: >
81+
:bulb: **Tip:** Have you already looked into our https://github.com/sourcebroker/t3api/discussions/categories/q-a?
82+
Maybe your problem has already been discussed there.

.github/ISSUE_TEMPLATE/config.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: Community support
4+
url: https://github.com/sourcebroker/t3api/discussions
5+
about: Please ask and answer questions here.
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Feature request
2+
description: Suggest an idea for this extension.
3+
title: "[FEATURE]"
4+
labels:
5+
- enhancement
6+
assignees:
7+
- kszymukowicz
8+
body:
9+
- type: textarea
10+
attributes:
11+
label: Is your feature request related to a problem?
12+
description: A clear description of what the problem is.
13+
placeholder: I'm always frustrated when [...]
14+
validations:
15+
required: true
16+
- type: textarea
17+
attributes:
18+
label: Describe the solution you'd like
19+
description: A clear description of what you want to happen.
20+
validations:
21+
required: true
22+
- type: textarea
23+
attributes:
24+
label: Describe alternatives you've considered
25+
description: A clear description of any alternative solutions or features you've considered.
26+
- type: textarea
27+
attributes:
28+
label: Additional context
29+
description: Add any other context or screenshots about the feature request here.
30+
- type: checkboxes
31+
id: terms
32+
attributes:
33+
label: Code of Conduct
34+
description: >
35+
By submitting this issue, you agree to follow our
36+
[Code of Conduct](https://github.com/sourcebroker/t3api/blob/main/CODE_OF_CONDUCT.md).
37+
options:
38+
- label: I agree to follow this project's Code of Conduct.
39+
required: true
40+
- type: markdown
41+
attributes:
42+
value: >
43+
:bulb: **Tip:** Have you already looked into https://github.com/sourcebroker/t3api/discussions/categories/ideas?
44+
Maybe your idea has already been discussed there.

.scrutinizer.yml

-3
This file was deleted.

CODE_OF_CONDUCT.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Code of Conduct
2+
3+
This project uses following code of conduct: https://typo3.org/community/values/code-of-conduct
4+
5+
By contributing to this project or engaging with community members, you agree to abide by this code of conduct.

CONTRIBUTING.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Contributing
2+
3+
Please have a look in the [development section][1] in documentation.
4+
5+
[1]: https://docs.typo3.org/p/sourcebroker/t3api/main/en-us/Miscellaneous/Development/Index.html

Documentation/Miscellaneous/Development/CommandsList/Index.rst

+12-6
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,22 @@ Example:
119119
.. _development_commands_list_ddev_next:
120120
:bash:`ddev next [major|minor|patch]`
121121
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
122-
This command will prepare t3api for next release.
122+
This command will help to tag next release of extension.
123123

124-
For now, the following files are changed with info about next version:
124+
It does several checks. Amongst other it:
125125

126-
* :file:`/ext_emconf.php`
127-
* :file:`/Documentation/guides.xml`
126+
1. Checks if you are on default branch.
127+
2. Checks if you are are up to date with remote default branch.
128+
3. Checks if you do not have any not pushed changes to remote.
129+
4. Checks validity of last tag.
130+
5. Increase version in few files:
128131

129-
Additionally it outputs a command you need to run to push changes and tag to git.
132+
* :file:`/ext_emconf.php`
133+
* :file:`/Documentation/guides.xml`
134+
135+
After all checks it outputs a command you need to run to push changes and tag to git.
130136

131137
Example output:
132138

133139
.. code-block:: bash
134-
git add Documentation/guides.xml ext_emconf.php && git commit -m 'Tag new version' && git tag -a '2.0.4' -m '2.0.4' && git push origin master --tags
140+
git add Documentation/guides.xml ext_emconf.php && git commit -m 'Tag version 3.1.0' && git tag -a '3.1.0' -m 'Version 3.1.0' -s && git push origin main --tags

0 commit comments

Comments
 (0)