Skip to content

Commit 89e0d62

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Improve squash merge commit author and co-author with private emails (go-gitea#22977) Fix broken Chroma CSS styles (go-gitea#23174) Add gradle samples in maven doc of packages (go-gitea#23374) Fix and move "Use this template" button (go-gitea#23398) [skip ci] Updated translations via Crowdin Add init file for Ubuntu (go-gitea#23362) Rename `canWriteUnit` to `canWriteProjects` (go-gitea#23386) Fix pull request update showing too many commits with multiple branches (go-gitea#22856) Fix incorrect NotFound conditions in org/projects.go (go-gitea#23384) Refactor merge/update git command calls (go-gitea#23366) Redirect to project again after editing it (go-gitea#23326) Add Gitea Community Code of Conduct (go-gitea#23188)
2 parents 62af2dc + d647e74 commit 89e0d62

File tree

29 files changed

+753
-190
lines changed

29 files changed

+753
-190
lines changed

.stylelintrc.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
plugins:
22
- stylelint-declaration-strict-value
33

4+
ignoreFiles:
5+
- "**/*.go"
6+
47
overrides:
58
- files: ["**/*.less"]
69
customSyntax: postcss-less
710
- files: ["**/chroma/*", "**/codemirror/*", "**/standalone/*", "**/console/*"]
811
rules:
912
scale-unlimited/declaration-strict-value: null
13+
- files: ["**/chroma/*", "**/codemirror/*"]
14+
rules:
15+
block-no-empty: null
1016

1117
rules:
1218
alpha-value-notation: null

CODE_OF_CONDUCT.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Gitea Community Code of Conduct
2+
3+
## About
4+
5+
Online communities include people from many different backgrounds. The Gitea contributors are committed to providing a friendly, safe and welcoming environment for all, regardless of gender identity and expression, sexual orientation, disabilities, neurodiversity, physical appearance, body size, ethnicity, nationality, race, age, religion, or similar personal characteristics.
6+
7+
The first goal of the Code of Conduct is to specify a baseline standard of behavior so that people with different social values and communication styles can talk about Gitea effectively, productively, and respectfully.
8+
9+
The second goal is to provide a mechanism for resolving conflicts in the community when they arise.
10+
11+
The third goal of the Code of Conduct is to make our community welcoming to people from different backgrounds. Diversity is critical to the project; for Gitea to be successful, it needs contributors and users from all backgrounds.
12+
13+
We believe that healthy debate and disagreement are essential to a healthy project and community. However, it is never ok to be disrespectful. We value diverse opinions, but we value respectful behavior more.
14+
15+
## Community values
16+
17+
These are the values to which people in the Gitea community should aspire.
18+
19+
- **Be friendly and welcoming.**
20+
- **Be patient.**
21+
- Remember that people have varying communication styles and that not everyone is using their native language. (Meaning and tone can be lost in translation.)
22+
- **Be thoughtful.**
23+
- Productive communication requires effort. Think about how your words will be interpreted.
24+
- Remember that sometimes it is best to refrain entirely from commenting.
25+
- **Be respectful.**
26+
- In particular, respect differences of opinion.
27+
- **Be charitable.**
28+
- Interpret the arguments of others in good faith, do not seek to disagree.
29+
- When we do disagree, try to understand why.
30+
- **Be constructive.**
31+
- Avoid derailing: stay on topic; if you want to talk about something else, start a new conversation.
32+
- Avoid unconstructive criticism: don't merely decry the current state of affairs; offer—or at least solicit—suggestions as to how things may be improved.
33+
- Avoid snarking (pithy, unproductive, sniping comments)
34+
- Avoid discussing potentially offensive or sensitive issues; this all too often leads to unnecessary conflict.
35+
- Avoid microaggressions (brief and commonplace verbal, behavioral and environmental indignities that communicate hostile, derogatory or negative slights and insults to a person or group).
36+
- **Be responsible.**
37+
- What you say and do matters. Take responsibility for your words and actions, including their consequences, whether intended or otherwise.
38+
39+
People are complicated. You should expect to be misunderstood and to misunderstand others; when this inevitably occurs, resist the urge to be defensive or assign blame. Try not to take offense where no offense was intended. Give people the benefit of the doubt. Even if the intent was to provoke, do not rise to it. It is the responsibility of all parties to de-escalate conflict when it arises.
40+
41+
## Code of Conduct
42+
43+
### Our Pledge
44+
45+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
46+
47+
### Our Standards
48+
49+
Examples of behavior that contributes to creating a positive environment include:
50+
51+
- Using welcoming and inclusive language
52+
- Being respectful of differing viewpoints and experiences
53+
- Gracefully accepting constructive criticism
54+
- Focusing on what is best for the community
55+
- Showing empathy towards other community members
56+
57+
Examples of unacceptable behavior by participants include:
58+
59+
- The use of sexualized language or imagery and unwelcome sexual attention or advances
60+
- Trolling, insulting/derogatory comments, and personal or political attacks
61+
- Public or private harassment
62+
- Publishing others’ private information, such as a physical or electronic address, without explicit permission
63+
- Other conduct which could reasonably be considered inappropriate in a professional setting
64+
65+
### Our Responsibilities
66+
67+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
68+
69+
Project maintainers have the right and responsibility to remove, edit, or reject: comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, as well as to ban (temporarily or permanently) any contributor for behaviors that they deem inappropriate, threatening, offensive, or harmful.
70+
71+
### Scope
72+
73+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
74+
75+
This Code of Conduct also applies outside the project spaces when the Project Stewards have a reasonable belief that an individual’s behavior may have a negative impact on the project or its community.
76+
77+
### Conflict Resolution
78+
79+
We do not believe that all conflict is bad; healthy debate and disagreement often yield positive results. However, it is never okay to be disrespectful or to engage in behavior that violates the project’s code of conduct.
80+
81+
If you see someone violating the code of conduct, you are encouraged to address the behavior directly with those involved. Many issues can be resolved quickly and easily, and this gives people more control over the outcome of their dispute. If you are unable to resolve the matter for any reason, or if the behavior is threatening or harassing, report it. We are dedicated to providing an environment where participants feel welcome and safe.
82+
83+
Reports should be directed to the Gitea Project Stewards at [email protected]. It is the Project Stewards’ duty to receive and address reported violations of the code of conduct. They will then work with a committee consisting of representatives from the technical-oversight-committee.
84+
85+
We will investigate every complaint, but you may not receive a direct response. We will use our discretion in determining when and how to follow up on reported incidents, which may range from not taking action to permanent expulsion from the project and project-sponsored spaces. Under normal circumstances, we will notify the accused of the report and provide them an opportunity to discuss it before any action is taken. If there is a consensus between maintainers that such an endeavor would be useless (i.e. in case of an obvious spammer), we reserve the right to take action without notifying the accused first. The identity of the reporter will be omitted from the details of the report supplied to the accused. In potentially harmful situations, such as ongoing harassment or threats to anyone’s safety, we may take action without notice.
86+
87+
### Attribution
88+
89+
This Code of Conduct is adapted from the Contributor Covenant, version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
90+
91+
## Summary
92+
93+
- Treat everyone with respect and kindness.
94+
- Be thoughtful in how you communicate.
95+
- Don’t be destructive or inflammatory.
96+
- If you encounter an issue, please mail [email protected].

contrib/init/ubuntu/gitea

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/bin/sh
2+
### BEGIN INIT INFO
3+
# Provides: gitea
4+
# Required-Start: $syslog $network
5+
# Required-Stop: $syslog
6+
# Default-Start: 2 3 4 5
7+
# Default-Stop: 0 1 6
8+
# Short-Description: A self-hosted Git service written in Go.
9+
# Description: A self-hosted Git service written in Go.
10+
### END INIT INFO
11+
12+
# Do NOT "set -e"
13+
14+
# PATH should only include /usr/* if it runs after the mountnfs.sh script
15+
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
16+
DESC="Gitea - Git with a cup of tea"
17+
NAME=gitea
18+
SERVICEVERBOSE=yes
19+
PIDFILE=/run/$NAME.pid
20+
SCRIPTNAME=/etc/init.d/$NAME
21+
WORKINGDIR=/var/lib/$NAME
22+
DAEMON=/usr/local/bin/$NAME
23+
DAEMON_ARGS="web -c /etc/$NAME/app.ini"
24+
USER=git
25+
STOP_SCHEDULE="${STOP_SCHEDULE:-QUIT/5/TERM/1/KILL/5}"
26+
27+
# Read configuration variable file if it is present
28+
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
29+
30+
# Exit if the package is not installed
31+
[ -x "$DAEMON" ] || exit 0
32+
33+
do_start()
34+
{
35+
GITEA_ENVS="USER=$USER GITEA_WORK_DIR=$WORKINGDIR HOME=/home/$USER"
36+
GITEA_EXEC="$DAEMON -- $DAEMON_ARGS"
37+
sh -c "start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile \\
38+
--background --chdir $WORKINGDIR --chuid $USER \\
39+
--exec /bin/bash -- -c '/usr/bin/env $GITEA_ENVS $GITEA_EXEC'"
40+
}
41+
42+
do_stop()
43+
{
44+
start-stop-daemon --stop --quiet --retry=$STOP_SCHEDULE --pidfile $PIDFILE --name $NAME --oknodo
45+
rm -f $PIDFILE
46+
}
47+
48+
do_status()
49+
{
50+
if [ -f $PIDFILE ]; then
51+
if kill -0 $(cat "$PIDFILE"); then
52+
echo "$NAME is running, PID is $(cat $PIDFILE)"
53+
else
54+
echo "$NAME process is dead, but pidfile exists"
55+
fi
56+
else
57+
echo "$NAME is not running"
58+
fi
59+
}
60+
61+
case "$1" in
62+
start)
63+
echo "Starting $DESC" "$NAME"
64+
do_start
65+
;;
66+
stop)
67+
echo "Stopping $DESC" "$NAME"
68+
do_stop
69+
;;
70+
status)
71+
do_status
72+
;;
73+
restart)
74+
echo "Restarting $DESC" "$NAME"
75+
do_stop
76+
do_start
77+
;;
78+
*)
79+
echo "Usage: $SCRIPTNAME {start|stop|status|restart}" >&2
80+
exit 2
81+
;;
82+
esac
83+
84+
exit 0

docs/content/doc/packages/maven.en-us.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Publish [Maven](https://maven.apache.org) packages for your user or organization
2323
## Requirements
2424

2525
To work with the Maven package registry, you can use [Maven](https://maven.apache.org/install.html) or [Gradle](https://gradle.org/install/).
26-
The following examples use `Maven`.
26+
The following examples use `Maven` and `Gradle Groovy`.
2727

2828
## Configuring the package registry
2929

@@ -73,6 +73,40 @@ Afterwards add the following sections to your project `pom.xml` file:
7373
| `access_token` | Your [personal access token]({{< relref "doc/developers/api-usage.en-us.md#authentication" >}}). |
7474
| `owner` | The owner of the package. |
7575

76+
### Gradle variant
77+
78+
When you plan to add some packages from Gitea instance in your project, you should add it in repositories section:
79+
80+
```groovy
81+
repositories {
82+
// other repositories
83+
maven { url "https://gitea.example.com/api/packages/{owner}/maven" }
84+
}
85+
```
86+
87+
In Groovy gradle you may include next script in your publishing part:
88+
89+
```groovy
90+
publishing {
91+
// other settings of publication
92+
repositories {
93+
maven {
94+
name = "Gitea"
95+
url = uri("https://gitea.example.com/api/packages/{owner}/maven")
96+
97+
credentials(HttpHeaderCredentials) {
98+
name = "Authorization"
99+
value = "token {access_token}"
100+
}
101+
102+
authentication {
103+
header(HttpHeaderAuthentication)
104+
}
105+
}
106+
}
107+
}
108+
```
109+
76110
## Publish a package
77111

78112
To publish a package simply run:
@@ -81,6 +115,12 @@ To publish a package simply run:
81115
mvn deploy
82116
```
83117

118+
Or call `gradle` with task `publishAllPublicationsToGiteaRepository` in case you are using gradle:
119+
120+
```groovy
121+
./gradlew publishAllPublicationsToGiteaRepository
122+
```
123+
84124
If you want to publish a prebuild package to the registry, you can use [`mvn deploy:deploy-file`](https://maven.apache.org/plugins/maven-deploy-plugin/deploy-file-mojo.html):
85125

86126
```shell
@@ -105,6 +145,12 @@ To install a Maven package from the package registry, add a new dependency to yo
105145
</dependency>
106146
```
107147

148+
And analog in gradle groovy:
149+
150+
```groovy
151+
implementation "com.test.package:test_project:1.0.0"
152+
```
153+
108154
Afterwards run:
109155

110156
```shell

modules/git/command.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ func (c *Command) AddDashesAndList(list ...string) *Command {
179179
}
180180

181181
// ToTrustedCmdArgs converts a list of strings (trusted as argument) to TrustedCmdArgs
182-
// In most cases, it shouldn't be used. Use AddXxx function instead
182+
// In most cases, it shouldn't be used. Use NewCommand().AddXxx() function instead
183183
func ToTrustedCmdArgs(args []string) TrustedCmdArgs {
184184
ret := make(TrustedCmdArgs, len(args))
185185
for i, arg := range args {

modules/git/commit.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,19 @@ func (c *Commit) HasPreviousCommit(commitHash SHA1) (bool, error) {
218218
return false, err
219219
}
220220

221+
// IsForcePush returns true if a push from oldCommitHash to this is a force push
222+
func (c *Commit) IsForcePush(oldCommitID string) (bool, error) {
223+
if oldCommitID == EmptySHA {
224+
return false, nil
225+
}
226+
oldCommit, err := c.repo.GetCommit(oldCommitID)
227+
if err != nil {
228+
return false, err
229+
}
230+
hasPreviousCommit, err := c.HasPreviousCommit(oldCommit.ID)
231+
return !hasPreviousCommit, err
232+
}
233+
221234
// CommitsBeforeLimit returns num commits before current revision
222235
func (c *Commit) CommitsBeforeLimit(num int) ([]*Commit, error) {
223236
return c.repo.getCommitsBeforeLimit(c.ID, num)

modules/git/repo_commit.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,27 @@ func (repo *Repository) CommitsBetweenLimit(last, before *Commit, limit, skip in
323323
return repo.parsePrettyFormatLogToList(bytes.TrimSpace(stdout))
324324
}
325325

326+
// CommitsBetweenNotBase returns a list that contains commits between [before, last), excluding commits in baseBranch.
327+
// If before is detached (removed by reset + push) it is not included.
328+
func (repo *Repository) CommitsBetweenNotBase(last, before *Commit, baseBranch string) ([]*Commit, error) {
329+
var stdout []byte
330+
var err error
331+
if before == nil {
332+
stdout, _, err = NewCommand(repo.Ctx, "rev-list").AddDynamicArguments(last.ID.String()).AddOptionValues("--not", baseBranch).RunStdBytes(&RunOpts{Dir: repo.Path})
333+
} else {
334+
stdout, _, err = NewCommand(repo.Ctx, "rev-list").AddDynamicArguments(before.ID.String()+".."+last.ID.String()).AddOptionValues("--not", baseBranch).RunStdBytes(&RunOpts{Dir: repo.Path})
335+
if err != nil && strings.Contains(err.Error(), "no merge base") {
336+
// future versions of git >= 2.28 are likely to return an error if before and last have become unrelated.
337+
// previously it would return the results of git rev-list before last so let's try that...
338+
stdout, _, err = NewCommand(repo.Ctx, "rev-list").AddDynamicArguments(before.ID.String(), last.ID.String()).AddOptionValues("--not", baseBranch).RunStdBytes(&RunOpts{Dir: repo.Path})
339+
}
340+
}
341+
if err != nil {
342+
return nil, err
343+
}
344+
return repo.parsePrettyFormatLogToList(bytes.TrimSpace(stdout))
345+
}
346+
326347
// CommitsBetweenIDs return commits between twoe commits
327348
func (repo *Repository) CommitsBetweenIDs(last, before string) ([]*Commit, error) {
328349
lastCommit, err := repo.GetCommit(last)

modules/repository/push.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
package repository
55

66
import (
7-
"context"
87
"strings"
98

10-
repo_model "code.gitea.io/gitea/models/repo"
119
"code.gitea.io/gitea/modules/git"
1210
)
1311

@@ -96,19 +94,3 @@ func (opts *PushUpdateOptions) RefName() string {
9694
func (opts *PushUpdateOptions) RepoFullName() string {
9795
return opts.RepoUserName + "/" + opts.RepoName
9896
}
99-
100-
// IsForcePush detect if a push is a force push
101-
func IsForcePush(ctx context.Context, opts *PushUpdateOptions) (bool, error) {
102-
if !opts.IsUpdateBranch() {
103-
return false, nil
104-
}
105-
106-
output, _, err := git.NewCommand(ctx, "rev-list", "--max-count=1").AddDynamicArguments(opts.OldCommitID, "^"+opts.NewCommitID).
107-
RunStdString(&git.RunOpts{Dir: repo_model.RepoPath(opts.RepoUserName, opts.RepoName)})
108-
if err != nil {
109-
return false, err
110-
} else if len(output) > 0 {
111-
return true, nil
112-
}
113-
return false, nil
114-
}

0 commit comments

Comments
 (0)