Skip to content

Commit 202a5bf

Browse files
authored
Merge branch 'master' into fix-13996-webhook-migration
2 parents 9325b77 + 80a299d commit 202a5bf

File tree

18 files changed

+153
-61
lines changed

18 files changed

+153
-61
lines changed

.github/issue_template.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
<!--
44
1. Please speak English, this is the language all maintainers can speak and write.
5-
2. Please ask questions or configuration/deploy problems on our Discord
5+
2. Please ask questions or configuration/deploy problems on our Discord
66
server (https://discord.gg/gitea) or forum (https://discourse.gitea.io).
77
3. Please take a moment to check that your issue doesn't already exist.
8-
4. Please give all relevant information below for bug reports, because
8+
4. Make sure it's not mentioned in the FAQ (https://docs.gitea.io/en-us/faq)
9+
5. Please give all relevant information below for bug reports, because
910
incomplete details will be handled as an invalid report.
1011
-->
1112

cmd/admin.go

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"errors"
1111
"fmt"
1212
"os"
13+
"strings"
1314
"text/tabwriter"
1415

1516
"code.gitea.io/gitea/models"
@@ -125,9 +126,22 @@ var (
125126
}
126127

127128
microcmdUserDelete = cli.Command{
128-
Name: "delete",
129-
Usage: "Delete specific user",
130-
Flags: []cli.Flag{idFlag},
129+
Name: "delete",
130+
Usage: "Delete specific user by id, name or email",
131+
Flags: []cli.Flag{
132+
cli.Int64Flag{
133+
Name: "id",
134+
Usage: "ID of user of the user to delete",
135+
},
136+
cli.StringFlag{
137+
Name: "username,u",
138+
Usage: "Username of the user to delete",
139+
},
140+
cli.StringFlag{
141+
Name: "email,e",
142+
Usage: "Email of the user to delete",
143+
},
144+
},
131145
Action: runDeleteUser,
132146
}
133147

@@ -463,18 +477,33 @@ func runListUsers(c *cli.Context) error {
463477
}
464478

465479
func runDeleteUser(c *cli.Context) error {
466-
if !c.IsSet("id") {
467-
return fmt.Errorf("--id flag is missing")
480+
if !c.IsSet("id") && !c.IsSet("username") && !c.IsSet("email") {
481+
return fmt.Errorf("You must provide the id, username or email of a user to delete")
468482
}
469483

470484
if err := initDB(); err != nil {
471485
return err
472486
}
473487

474-
user, err := models.GetUserByID(c.Int64("id"))
488+
var err error
489+
var user *models.User
490+
if c.IsSet("email") {
491+
user, err = models.GetUserByEmail(c.String("email"))
492+
} else if c.IsSet("username") {
493+
user, err = models.GetUserByName(c.String("username"))
494+
} else {
495+
user, err = models.GetUserByID(c.Int64("id"))
496+
}
475497
if err != nil {
476498
return err
477499
}
500+
if c.IsSet("username") && user.LowerName != strings.ToLower(strings.TrimSpace(c.String("username"))) {
501+
return fmt.Errorf("The user %s who has email %s does not match the provided username %s", user.Name, c.String("email"), c.String("username"))
502+
}
503+
504+
if c.IsSet("id") && user.ID != c.Int64("id") {
505+
return fmt.Errorf("The user %s does not match the provided id %d", user.Name, c.Int64("id"))
506+
}
478507

479508
return models.DeleteUser(user)
480509
}

custom/conf/app.example.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ PROJECT_BOARD_BASIC_KANBAN_TYPE = To Do, In Progress, Done
1717
PROJECT_BOARD_BUG_TRIAGE_TYPE = Needs Triage, High Priority, Low Priority, Closed
1818

1919
[repository]
20+
; Root path for storing all repository data. It must be an absolute path. By default it is stored in a sub-directory of `APP_DATA_PATH`.
2021
ROOT =
22+
; The script type this server supports. Usually this is `bash`, but some users report that only `sh` is available.
2123
SCRIPT_TYPE = bash
2224
; DETECTED_CHARSETS_ORDER tie-break order for detected charsets.
2325
; If the charsets have equal confidence, tie-breaking will be done by order in this list

docs/content/doc/advanced/config-cheat-sheet.en-us.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
4242

4343
## Repository (`repository`)
4444

45-
- `ROOT`: **~/gitea-repositories/**: Root path for storing all repository data. It must be
46-
an absolute path.
45+
- `ROOT`: **data/gitea-repositories/**: Root path for storing all repository data. It must be
46+
an absolute path. By default it is stored in a sub-directory of `APP_DATA_PATH`.
4747
- `SCRIPT_TYPE`: **bash**: The script type this server supports. Usually this is `bash`,
4848
but some users report that only `sh` is available.
4949
- `DETECTED_CHARSETS_ORDER`: **UTF-8, UTF-16BE, UTF-16LE, UTF-32BE, UTF-32LE, ISO-8859, windows-1252, ISO-8859, windows-1250, ISO-8859, ISO-8859, ISO-8859, windows-1253, ISO-8859, windows-1255, ISO-8859, windows-1251, windows-1256, KOI8-R, ISO-8859, windows-1254, Shift_JIS, GB18030, EUC-JP, EUC-KR, Big5, ISO-2022, ISO-2022, ISO-2022, IBM424_rtl, IBM424_ltr, IBM420_rtl, IBM420_ltr**: Tie-break order of detected charsets - if the detected charsets have equal confidence, charsets earlier in the list will be chosen in preference to those later. Adding `defaults` will place the unnamed charsets at that point.

docs/content/doc/help/faq.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ https://github.com/loganinak/MigrateGitlabToGogs
6464
- Windows: Environment variable `USERPROFILE`, else environment variables `HOMEDRIVE`+`HOMEPATH`
6565
- RepoRootPath
6666
- `ROOT` in `app.ini`
67-
- Else `%(HomeDir)/gitea-repositories`
67+
- Else `%(AppDataPath)/gitea-repositories`
6868
- INI (config file)
6969
- `-c` flag
7070
- Else `%(CustomPath)/conf/app.ini`

docs/content/doc/installation/with-docker.en-us.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ services:
9191
- /etc/timezone:/etc/timezone:ro
9292
- /etc/localtime:/etc/localtime:ro
9393
ports:
94-
- - "3000:3000"
95-
- - "222:22"
96-
+ - "8080:3000"
97-
+ - "2221:22"
94+
- - "3000:3000"
95+
- - "222:22"
96+
+ - "8080:3000"
97+
+ - "2221:22"
9898
```
9999

100100
## Databases
@@ -118,11 +118,11 @@ services:
118118
environment:
119119
- USER_UID=1000
120120
- USER_GID=1000
121-
+ - DB_TYPE=mysql
122-
+ - DB_HOST=db:3306
123-
+ - DB_NAME=gitea
124-
+ - DB_USER=gitea
125-
+ - DB_PASSWD=gitea
121+
+ - DB_TYPE=mysql
122+
+ - DB_HOST=db:3306
123+
+ - DB_NAME=gitea
124+
+ - DB_USER=gitea
125+
+ - DB_PASSWD=gitea
126126
restart: always
127127
networks:
128128
- gitea
@@ -169,11 +169,11 @@ services:
169169
environment:
170170
- USER_UID=1000
171171
- USER_GID=1000
172-
+ - DB_TYPE=postgres
173-
+ - DB_HOST=db:5432
174-
+ - DB_NAME=gitea
175-
+ - DB_USER=gitea
176-
+ - DB_PASSWD=gitea
172+
+ - DB_TYPE=postgres
173+
+ - DB_HOST=db:5432
174+
+ - DB_NAME=gitea
175+
+ - DB_USER=gitea
176+
+ - DB_PASSWD=gitea
177177
restart: always
178178
networks:
179179
- gitea
@@ -226,8 +226,8 @@ services:
226226
networks:
227227
- gitea
228228
volumes:
229-
- - ./gitea:/data
230-
+ - gitea:/data
229+
- - ./gitea:/data
230+
+ - gitea:/data
231231
- /etc/timezone:/etc/timezone:ro
232232
- /etc/localtime:/etc/localtime:ro
233233
ports:

docs/content/doc/usage/command-line.en-us.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ Admin operations:
6969
- `gitea admin user list`
7070
- `delete`:
7171
- Options:
72-
- `--id`: ID of user to be deleted. Required.
72+
- `--email`: Email of the user to be deleted.
73+
- `--username`: Username of user to be deleted.
74+
- `--id`: ID of user to be deleted.
75+
- One of `--id`, `--username` or `--email` is required. If more than one is provided then all have to match.
7376
- Examples:
7477
- `gitea admin user delete --id 1`
7578
- `create`: - Options: - `--name value`: Username. Required. As of gitea 1.9.0, use the `--username` flag instead. - `--username value`: Username. Required. New in gitea 1.9.0. - `--password value`: Password. Required. - `--email value`: Email. Required. - `--admin`: If provided, this makes the user an admin. Optional. - `--access-token`: If provided, an access token will be created for the user. Optional. (default: false). - `--must-change-password`: If provided, the created user will be required to choose a newer password after

models/user.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@ func (u *User) GetOwnedOrganizations() (err error) {
538538
}
539539

540540
// GetOrganizations returns paginated organizations that user belongs to.
541+
// TODO: does not respect All and show orgs you privately participate
541542
func (u *User) GetOrganizations(opts *SearchOrganizationsOptions) error {
542543
sess := x.NewSession()
543544
defer sess.Close()

modules/git/command.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ func (c *Command) RunInDirTimeoutEnvFullPipelineFunc(env []string, timeout time.
153153
err := fn(ctx, cancel)
154154
if err != nil {
155155
cancel()
156+
_ = cmd.Wait()
156157
return err
157158
}
158159
}

modules/setting/repository.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import (
1010
"strings"
1111

1212
"code.gitea.io/gitea/modules/log"
13-
14-
"github.com/unknwon/com"
1513
)
1614

1715
// enumerates all the policy repository creating
@@ -249,19 +247,14 @@ var (
249247
)
250248

251249
func newRepository() {
252-
homeDir, err := com.HomeDir()
253-
if err != nil {
254-
log.Fatal("Failed to get home directory: %v", err)
255-
}
256-
homeDir = strings.ReplaceAll(homeDir, "\\", "/")
257-
250+
var err error
258251
// Determine and create root git repository path.
259252
sec := Cfg.Section("repository")
260253
Repository.DisableHTTPGit = sec.Key("DISABLE_HTTP_GIT").MustBool()
261254
Repository.UseCompatSSHURI = sec.Key("USE_COMPAT_SSH_URI").MustBool()
262255
Repository.MaxCreationLimit = sec.Key("MAX_CREATION_LIMIT").MustInt(-1)
263256
Repository.DefaultBranch = sec.Key("DEFAULT_BRANCH").MustString(Repository.DefaultBranch)
264-
RepoRootPath = sec.Key("ROOT").MustString(path.Join(homeDir, "gitea-repositories"))
257+
RepoRootPath = sec.Key("ROOT").MustString(path.Join(AppDataPath, "gitea-repositories"))
265258
forcePathSeparator(RepoRootPath)
266259
if !filepath.IsAbs(RepoRootPath) {
267260
RepoRootPath = filepath.Join(AppWorkPath, RepoRootPath)

0 commit comments

Comments
 (0)