go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
45.08k stars 5.49k forks source link

push reject: Push rejected Push xx to origin/xx was rejected by remote #11420

Closed hisune closed 4 years ago

hisune commented 4 years ago

Description

cant push code to branch, but pull is ok

log:

2020/05/15 18:55:40 modules/ssh/ssh.go:63:sessionHandler() [T] SSH: Payload: git-upload-pack 'xx/oo.git'
2020/05/15 18:55:40 modules/ssh/ssh.go:66:sessionHandler() [T] SSH: Arguments: [serv key-51 --config=/home/git/gitea/custom/conf/app.ini]
2020/05/15 18:55:40 ...s/auth/sso/oauth2.go:33:CheckOAuthAccessToken() [T] ParseOAuth2Token: signature is invalid
zeripath commented 4 years ago

Any chance we could have some more of the logs?

hisune commented 4 years ago

push log:

2020/05/18 11:21:36 .../xorm/session_raw.go:78:queryRows() [I] [SQL] SELECT `id`, `owner_id`, `name`, `fingerprint`, `content`, `mode`, `type`, `login_source_id`, `created_unix`, `updated_unix` FROM `public_key` WHERE (content like ?) LIMIT 1 []interface {}{"ssh-rsa {MY_KEY}HefUjLQp3Tw==%"} - took: 3.725969ms
2020/05/18 11:21:36 modules/ssh/ssh.go:63:sessionHandler() [T] SSH: Payload: git-receive-pack 'gogogo/bm.git'
2020/05/18 11:21:36 modules/ssh/ssh.go:66:sessionHandler() [T] SSH: Arguments: [serv key-51 --config=/home/git/gitea/custom/conf/app.ini]
2020/05/18 11:21:36 ...s/auth/sso/oauth2.go:33:CheckOAuthAccessToken() [T] ParseOAuth2Token: signature is invalid
2020/05/18 11:21:36 ...s/context/context.go:330:func1() [D] Session ID: 4b12705d1f19b339
2020/05/18 11:21:36 ...s/context/context.go:331:func1() [D] CSRF Token: KQAL8FRZ-idPh_zZg9VbouAlt9E6MTU4OTc3MjA5NjIxMDI5ODgxMQ
2020/05/18 11:21:36 .../xorm/session_raw.go:78:queryRows() [I] [SQL] SELECT repository.* FROM `repository` INNER JOIN `user` ON `user`.id = repository.owner_id WHERE (repository.lower_name = ?) AND (`user`.lower_name = ?) LIMIT 1 []interface {}{"bm", "gogogo"} - took: 4.077065ms
2020/05/18 11:21:36 .../xorm/session_raw.go:78:queryRows() [I] [SQL] SELECT `id`, `owner_id`, `name`, `fingerprint`, `content`, `mode`, `type`, `login_source_id`, `created_unix`, `updated_unix` FROM `public_key` WHERE `id`=? LIMIT 1 []interface {}{51} - took: 4.905847ms
2020/05/18 11:21:36 .../xorm/session_raw.go:78:queryRows() [I] [SQL] SELECT `id`, `lower_name`, `name`, `full_name`, `email`, `keep_email_private`, `email_notifications_preference`, `passwd`, `passwd_hash_algo`, `must_change_password`, `login_type`, `login_source`, `login_name`, `type`, `location`, `website`, `rands`, `salt`, `language`, `description`, `created_unix`, `updated_unix`, `last_login_unix`, `last_repo_visibility`, `max_repo_creation`, `is_active`, `is_admin`, `allow_git_hook`, `allow_import_local`, `allow_create_organization`, `prohibit_login`, `avatar`, `avatar_email`, `use_custom_avatar`, `num_followers`, `num_following`, `num_stars`, `num_repos`, `num_teams`, `num_members`, `visibility`, `repo_admin_change_team_access`, `diff_view_style`, `theme` FROM `user` WHERE `id`=? LIMIT 1 []interface {}{1} - took: 608.719µs
2020/05/18 11:21:36 .../xorm/session_raw.go:78:queryRows() [I] [SQL] SELECT `id`, `lower_name`, `name`, `full_name`, `email`, `keep_email_private`, `email_notifications_preference`, `passwd`, `passwd_hash_algo`, `must_change_password`, `login_type`, `login_source`, `login_name`, `type`, `location`, `website`, `rands`, `salt`, `language`, `description`, `created_unix`, `updated_unix`, `last_login_unix`, `last_repo_visibility`, `max_repo_creation`, `is_active`, `is_admin`, `allow_git_hook`, `allow_import_local`, `allow_create_organization`, `prohibit_login`, `avatar`, `avatar_email`, `use_custom_avatar`, `num_followers`, `num_following`, `num_stars`, `num_repos`, `num_teams`, `num_members`, `visibility`, `repo_admin_change_team_access`, `diff_view_style`, `theme` FROM `user` WHERE `id`=? LIMIT 1 []interface {}{2} - took: 638.794µs
2020/05/18 11:21:36 .../xorm/session_raw.go:78:queryRows() [I] [SQL] SELECT `id`, `repo_id`, `user_id`, `mode` FROM `collaboration` WHERE `repo_id`=? AND `user_id`=? LIMIT 1 []interface {}{10, 1} - took: 594.03µs
2020/05/18 11:21:36 .../xorm/session_raw.go:78:queryRows() [I] [SQL] SELECT `id`, `repo_id`, `type`, `config`, `created_unix` FROM `repo_unit` WHERE (repo_id = ?) []interface {}{10} - took: 774.536µs
2020/05/18 11:21:36 ...s/repo_permission.go:154:func1() [T] Permission Loaded for 824768905712:test in 824768905792:gogogo/bm:
    Permissions: AccessMode: 824768906352:owner, 5 Units, 0 UnitsMode(s): [ 
    Units[0]: ID: 824768905888 RepoID: 824768905920 Type: 824768906384:UnitTypeCode Config: {}
    Units[1]: ID: 824768905984 RepoID: 824768906016 Type: 824768906416:UnitTypeIssues Config: {"EnableTimetracker":true,"AllowOnlyContributorsToTrackTime":true,"EnableDependencies":true}
    Units[2]: ID: 824768906080 RepoID: 824768906112 Type: 824768906448:UnitTypePullRequests Config: {"IgnoreWhitespaceConflicts":false,"AllowMerge":true,"AllowRebase":true,"AllowRebaseMerge":true,"AllowSquash":true}
    Units[3]: ID: 824768906176 RepoID: 824768906208 Type: 824768906480:UnitTypeReleases Config: {}
    Units[4]: ID: 824768906272 RepoID: 824768906304 Type: 824768906512:UnitTypeWiki Config: {} ]
2020/05/18 11:21:36 ...ters/private/serv.go:363:ServCommand() [D] Serv Results:
    IsWiki: false
    IsDeployKey: false
    KeyID: 51   KeyName: hi@test.com
    UserName: test
    UserID: 1
    OwnerName: gogogo
    RepoName: bm
    RepoID: 10
2020/05/18 11:21:37 ...s/auth/sso/oauth2.go:33:CheckOAuthAccessToken() [T] ParseOAuth2Token: signature is invalid
2020/05/18 11:21:37 ...s/context/context.go:330:func1() [D] Session ID: 2cf6ac8c934e9be8
2020/05/18 11:21:37 ...s/context/context.go:331:func1() [D] CSRF Token: I_AQpQ3F3z6wtM0ERM7Yla_9vxk6MTU4OTc3MjA5NzM3Nzk4MDE3MQ
2020/05/18 11:21:37 .../xorm/session_raw.go:78:queryRows() [I] [SQL] SELECT count(*) FROM `public_key` WHERE `id`=? []interface {}{51} - took: 465.181µs
2020/05/18 11:21:37 .../xorm/session_raw.go:196:exec() [I] [SQL] UPDATE `public_key` SET `updated_unix` = ? WHERE `id`=? []interface {}{1589772097, 51} - took: 8.999802ms
2020/05/18 11:21:37 .../xorm/session_raw.go:78:queryRows() [I] [SQL] SELECT `id`, `key_id`, `repo_id`, `name`, `fingerprint`, `mode`, `created_unix`, `updated_unix` FROM `deploy_key` WHERE `key_id`=? AND `repo_id`=? LIMIT 1 []interface {}{51, 10} - took: 776.585µs

terminal output:

Counting objects: 9, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (9/9), done.
Writing objects: 100% (9/9), 1.07 KiB | 1.07 MiB/s, done.
Total 9 (delta 5), reused 1 (delta 0)
To MYDOMAIN.com:gogogo/bm.git
 ! [remote rejected]     dev -> dev (pre-receive hook declined)
error: failed to push some refs to 'git@MYDOMAIN:gogogo/bm.git'
zeripath commented 4 years ago

You've stopped the logs too early. You've given us the logs that show that the serv command works but then but given me any logs for the pre-receive

zeripath commented 4 years ago

(Ignore the oauth2 log comment it's entirely irrelevant. There's a reason why that is at trace level.)

hisune commented 4 years ago

These logs is repeated twice in one push


2020/05/18 12:33:22 .../xorm/session_raw.go:78:queryRows() [I] [SQL] SELECT `id`, `owner_id`, `name`, `fingerprint`, `content`, `mode`, `type`, `login_source_id`, `created_unix`, `updated_unix` FROM `public_key` WHERE (content like ?) LIMIT 1 []interface {}{"ssh-rsa {MY_KEY}3Tw==%"} - took: 61.248964ms
2020/05/18 12:33:22 modules/ssh/ssh.go:63:sessionHandler() [T] SSH: Payload: git-receive-pack 'gogogo/bm.git'
2020/05/18 12:33:22 modules/ssh/ssh.go:66:sessionHandler() [T] SSH: Arguments: [serv key-51 --config=/home/git/gitea/custom/conf/app.ini]
2020/05/18 12:33:22 ...s/auth/sso/oauth2.go:33:CheckOAuthAccessToken() [T] ParseOAuth2Token: signature is invalid
2020/05/18 12:33:22 ...s/context/context.go:330:func1() [D] Session ID: 3b246b17f6137643
2020/05/18 12:33:22 ...s/context/context.go:331:func1() [D] CSRF Token: _BkQca7Kzg7xyI45dC3HehJ1pls6MTU4OTc3NjQwMjIwMDY0Njg5NQ
2020/05/18 12:33:22 .../xorm/session_raw.go:78:queryRows() [I] [SQL] SELECT repository.* FROM `repository` INNER JOIN `user` ON `user`.id = repository.owner_id WHERE (repository.lower_name = ?) AND (`user`.lower_name = ?) LIMIT 1 []interface {}{"bm", "gogogo"} - took: 1.240352ms
2020/05/18 12:33:22 .../xorm/session_raw.go:78:queryRows() [I] [SQL] SELECT `id`, `owner_id`, `name`, `fingerprint`, `content`, `mode`, `type`, `login_source_id`, `created_unix`, `updated_unix` FROM `public_key` WHERE `id`=? LIMIT 1 []interface {}{51} - took: 2.973222ms
2020/05/18 12:33:22 .../xorm/session_raw.go:78:queryRows() [I] [SQL] SELECT `id`, `lower_name`, `name`, `full_name`, `email`, `keep_email_private`, `email_notifications_preference`, `passwd`, `passwd_hash_algo`, `must_change_password`, `login_type`, `login_source`, `login_name`, `type`, `location`, `website`, `rands`, `salt`, `language`, `description`, `created_unix`, `updated_unix`, `last_login_unix`, `last_repo_visibility`, `max_repo_creation`, `is_active`, `is_admin`, `allow_git_hook`, `allow_import_local`, `allow_create_organization`, `prohibit_login`, `avatar`, `avatar_email`, `use_custom_avatar`, `num_followers`, `num_following`, `num_stars`, `num_repos`, `num_teams`, `num_members`, `visibility`, `repo_admin_change_team_access`, `diff_view_style`, `theme` FROM `user` WHERE `id`=? LIMIT 1 []interface {}{1} - took: 600.356µs
2020/05/18 12:33:22 .../xorm/session_raw.go:78:queryRows() [I] [SQL] SELECT `id`, `lower_name`, `name`, `full_name`, `email`, `keep_email_private`, `email_notifications_preference`, `passwd`, `passwd_hash_algo`, `must_change_password`, `login_type`, `login_source`, `login_name`, `type`, `location`, `website`, `rands`, `salt`, `language`, `description`, `created_unix`, `updated_unix`, `last_login_unix`, `last_repo_visibility`, `max_repo_creation`, `is_active`, `is_admin`, `allow_git_hook`, `allow_import_local`, `allow_create_organization`, `prohibit_login`, `avatar`, `avatar_email`, `use_custom_avatar`, `num_followers`, `num_following`, `num_stars`, `num_repos`, `num_teams`, `num_members`, `visibility`, `repo_admin_change_team_access`, `diff_view_style`, `theme` FROM `user` WHERE `id`=? LIMIT 1 []interface {}{2} - took: 540.683µs
2020/05/18 12:33:22 .../xorm/session_raw.go:78:queryRows() [I] [SQL] SELECT `id`, `repo_id`, `user_id`, `mode` FROM `collaboration` WHERE `repo_id`=? AND `user_id`=? LIMIT 1 []interface {}{10, 1} - took: 674.416µs
2020/05/18 12:33:22 .../xorm/session_raw.go:78:queryRows() [I] [SQL] SELECT `id`, `repo_id`, `type`, `config`, `created_unix` FROM `repo_unit` WHERE (repo_id = ?) []interface {}{10} - took: 653.387µs
2020/05/18 12:33:22 ...s/repo_permission.go:154:func1() [T] Permission Loaded for 824710804176:test in 824710804384:gogogo/bm:
    Permissions: AccessMode: 824710806448:owner, 5 Units, 0 UnitsMode(s): [ 
    Units[0]: ID: 824710804608 RepoID: 824710804720 Type: 824710806736:UnitTypeCode Config: {}
    Units[1]: ID: 824710804832 RepoID: 824710804944 Type: 824710806832:UnitTypeIssues Config: {"EnableTimetracker":true,"AllowOnlyContributorsToTrackTime":true,"EnableDependencies":true}
    Units[2]: ID: 824710805056 RepoID: 824710805216 Type: 824710807104:UnitTypePullRequests Config: {"IgnoreWhitespaceConflicts":false,"AllowMerge":true,"AllowRebase":true,"AllowRebaseMerge":true,"AllowSquash":true}
    Units[3]: ID: 824710805648 RepoID: 824710805872 Type: 824710807232:UnitTypeReleases Config: {}
    Units[4]: ID: 824710806096 RepoID: 824710806272 Type: 824710807376:UnitTypeWiki Config: {} ]
2020/05/18 12:33:22 ...ters/private/serv.go:363:ServCommand() [D] Serv Results:
    IsWiki: false
    IsDeployKey: false
    KeyID: 51   KeyName: hi@test.com
    UserName: test
    UserID: 1
    OwnerName: gogogo
    RepoName: bm
    RepoID: 10
2020/05/18 12:33:23 ...s/auth/sso/oauth2.go:33:CheckOAuthAccessToken() [T] ParseOAuth2Token: signature is invalid
2020/05/18 12:33:23 ...s/context/context.go:330:func1() [D] Session ID: 22e24d328163bbd8
2020/05/18 12:33:23 ...s/context/context.go:331:func1() [D] CSRF Token: UMUFtYx0GPsz96eDhVLA3jcvvEs6MTU4OTc3NjQwMzQzOTEwMzQ3OQ
2020/05/18 12:33:23 .../xorm/session_raw.go:78:queryRows() [I] [SQL] SELECT count(*) FROM `public_key` WHERE `id`=? []interface {}{51} - took: 546.312µs
2020/05/18 12:33:23 .../xorm/session_raw.go:196:exec() [I] [SQL] UPDATE `public_key` SET `updated_unix` = ? WHERE `id`=? []interface {}{1589776403, 51} - took: 6.034459ms
2020/05/18 12:33:23 .../xorm/session_raw.go:78:queryRows() [I] [SQL] SELECT `id`, `key_id`, `repo_id`, `name`, `fingerprint`, `mode`, `created_unix`, `updated_unix` FROM `deploy_key` WHERE `key_id`=? AND `repo_id`=? LIMIT 1 []interface {}{51, 10} - took: 570.01µs

!!!!!!!!!!!!!!!->>>>> <after 4 minutes, gitea.log output updated>

2020/05/18 12:37:01 .../xorm/session_raw.go:78:queryRows() [I] [SQL] SELECT `id`, `owner_id`, `name`, `fingerprint`, `content`, `mode`, `type`, `login_source_id`, `created_unix`, `updated_unix` FROM `public_key` WHERE (content like ?) LIMIT 1 []interface {}{"ssh-rsa {MY_KEY}3Tw==%"} - took: 30.839631ms
2020/05/18 12:37:01 modules/ssh/ssh.go:63:sessionHandler() [T] SSH: Payload: git-upload-pack 'gogogo/bm.git'
2020/05/18 12:37:01 modules/ssh/ssh.go:66:sessionHandler() [T] SSH: Arguments: [serv key-51 --config=/home/git/gitea/custom/conf/app.ini]
2020/05/18 12:37:01 ...s/auth/sso/oauth2.go:33:CheckOAuthAccessToken() [T] ParseOAuth2Token: signature is invalid
2020/05/18 12:37:01 ...s/context/context.go:330:func1() [D] Session ID: 5675916ce99a7679
2020/05/18 12:37:01 ...s/context/context.go:331:func1() [D] CSRF Token: l0k5ZD8k-jgQxwjwL15ox-GtUWc6MTU4OTc3NjYyMTk0NDU3NzgxMw
2020/05/18 12:37:01 .../xorm/session_raw.go:78:queryRows() [I] [SQL] SELECT repository.* FROM `repository` INNER JOIN `user` ON `user`.id = repository.owner_id WHERE (repository.lower_name = ?) AND (`user`.lower_name = ?) LIMIT 1 []interface {}{"bm", "gogogo"} - took: 1.101055ms
2020/05/18 12:37:01 .../xorm/session_raw.go:78:queryRows() [I] [SQL] SELECT `id`, `owner_id`, `name`, `fingerprint`, `content`, `mode`, `type`, `login_source_id`, `created_unix`, `updated_unix` FROM `public_key` WHERE `id`=? LIMIT 1 []interface {}{51} - took: 469.801µs
2020/05/18 12:37:01 .../xorm/session_raw.go:78:queryRows() [I] [SQL] SELECT `id`, `lower_name`, `name`, `full_name`, `email`, `keep_email_private`, `email_notifications_preference`, `passwd`, `passwd_hash_algo`, `must_change_password`, `login_type`, `login_source`, `login_name`, `type`, `location`, `website`, `rands`, `salt`, `language`, `description`, `created_unix`, `updated_unix`, `last_login_unix`, `last_repo_visibility`, `max_repo_creation`, `is_active`, `is_admin`, `allow_git_hook`, `allow_import_local`, `allow_create_organization`, `prohibit_login`, `avatar`, `avatar_email`, `use_custom_avatar`, `num_followers`, `num_following`, `num_stars`, `num_repos`, `num_teams`, `num_members`, `visibility`, `repo_admin_change_team_access`, `diff_view_style`, `theme` FROM `user` WHERE `id`=? LIMIT 1 []interface {}{1} - took: 645.073µs
2020/05/18 12:37:01 .../xorm/session_raw.go:78:queryRows() [I] [SQL] SELECT `id`, `lower_name`, `name`, `full_name`, `email`, `keep_email_private`, `email_notifications_preference`, `passwd`, `passwd_hash_algo`, `must_change_password`, `login_type`, `login_source`, `login_name`, `type`, `location`, `website`, `rands`, `salt`, `language`, `description`, `created_unix`, `updated_unix`, `last_login_unix`, `last_repo_visibility`, `max_repo_creation`, `is_active`, `is_admin`, `allow_git_hook`, `allow_import_local`, `allow_create_organization`, `prohibit_login`, `avatar`, `avatar_email`, `use_custom_avatar`, `num_followers`, `num_following`, `num_stars`, `num_repos`, `num_teams`, `num_members`, `visibility`, `repo_admin_change_team_access`, `diff_view_style`, `theme` FROM `user` WHERE `id`=? LIMIT 1 []interface {}{2} - took: 653.284µs
2020/05/18 12:37:01 .../xorm/session_raw.go:78:queryRows() [I] [SQL] SELECT `id`, `repo_id`, `user_id`, `mode` FROM `collaboration` WHERE `repo_id`=? AND `user_id`=? LIMIT 1 []interface {}{10, 1} - took: 641.39µs
2020/05/18 12:37:01 .../xorm/session_raw.go:78:queryRows() [I] [SQL] SELECT `id`, `repo_id`, `type`, `config`, `created_unix` FROM `repo_unit` WHERE (repo_id = ?) []interface {}{10} - took: 699.478µs
2020/05/18 12:37:01 ...s/repo_permission.go:154:func1() [T] Permission Loaded for 824710804048:test in 824710804176:gogogo/bm:
    Permissions: AccessMode: 824710806240:owner, 5 Units, 0 UnitsMode(s): [ 
    Units[0]: ID: 824710804400 RepoID: 824710804528 Type: 824710806352:UnitTypeCode Config: {}
    Units[1]: ID: 824710804720 RepoID: 824710804784 Type: 824710806448:UnitTypeIssues Config: {"EnableTimetracker":true,"AllowOnlyContributorsToTrackTime":true,"EnableDependencies":true}
    Units[2]: ID: 824710804944 RepoID: 824710805008 Type: 824710806736:UnitTypePullRequests Config: {"IgnoreWhitespaceConflicts":false,"AllowMerge":true,"AllowRebase":true,"AllowRebaseMerge":true,"AllowSquash":true}
    Units[3]: ID: 824710805216 RepoID: 824710805552 Type: 824710806832:UnitTypeReleases Config: {}
    Units[4]: ID: 824710805872 RepoID: 824710806064 Type: 824710807104:UnitTypeWiki Config: {} ]
2020/05/18 12:37:01 ...ters/private/serv.go:363:ServCommand() [D] Serv Results:
    IsWiki: false
    IsDeployKey: false
    KeyID: 51   KeyName: hi@test.com
    UserName: test
    UserID: 1
    OwnerName: gogogo
    RepoName: bm
    RepoID: 10
2020/05/18 12:37:03 ...s/auth/sso/oauth2.go:33:CheckOAuthAccessToken() [T] ParseOAuth2Token: signature is invalid
2020/05/18 12:37:03 ...s/context/context.go:330:func1() [D] Session ID: f2e8a47972565aa6
2020/05/18 12:37:03 ...s/context/context.go:331:func1() [D] CSRF Token: XrhIeqsMSAFPo4tVlPTy954ahMY6MTU4OTc3NjYyMzAyMzQ2MzczNw
2020/05/18 12:37:03 .../xorm/session_raw.go:78:queryRows() [I] [SQL] SELECT count(*) FROM `public_key` WHERE `id`=? []interface {}{51} - took: 696.665µs
2020/05/18 12:37:03 .../xorm/session_raw.go:196:exec() [I] [SQL] UPDATE `public_key` SET `updated_unix` = ? WHERE `id`=? []interface {}{1589776623, 51} - took: 34.64768ms
2020/05/18 12:37:03 .../xorm/session_raw.go:78:queryRows() [I] [SQL] SELECT `id`, `key_id`, `repo_id`, `name`, `fingerprint`, `mode`, `created_unix`, `updated_unix` FROM `deploy_key` WHERE `key_id`=? AND `repo_id`=? LIMIT 1 []interface {}{51, 10} - took: 761.047µs

the /home/git/gogs/log/hooks/pre-receive.log is empty:

[hooks]# ll
total 32
-rw-rw---- 1 git git   980 May 18 12:04 post-receive.log
-rwx------ 1 git git  8355 May 15 18:58 post-receive.log.2020-05-15
-rw-rw---- 1 git git 13720 May 17 22:39 post-receive.log.2020-05-17
-rw-rw---- 1 git git     0 May 18 10:36 pre-receive.log
-rwx------ 1 git git     0 May 15 13:15 pre-receive.log.2020-05-15
-rw-rw---- 1 git git     0 May 17 09:34 pre-receive.log.2020-05-17
-rwx------ 1 git git     0 Sep 30  2019 update.log
-rwx------ 1 git git     0 Sep 29  2019 update.log.2019-09-29
zeripath commented 4 years ago

There is no pre-receive log. It should be in the main log. We're also missing routing information and in general I don't need to see SQL logs.

You need to read the logging documentation on Gitea.io. However set your logging to:

[database]
LOG_SQL=false

...

[log]
MODE = console
LEVEL = debug
ROOT_PATH = /home/andrew/src/go/gitea/log
REDIRECT_MACARON_LOG = true
MACARON = console
ROUTER = console
XORM = console

I need to see the logs just after the ones that you have posted. Those just show me that serv is working perfectly but we know that because git is telling me that pre-receive failing which occurs after serv.

zeripath commented 4 years ago

Let me explain for the millionth time what happens when you push:

So we know that serv is working but I can't tell from your logs if the Gitea hook is trying to communicate with the server or not.

The usual problem is that the hook files in the repository are not executable or they are old - hence the advice to regenerate these.

hisune commented 4 years ago

thx, I have modified the ini file, all logs are as follows

2020/05/18 15:27:07 Started GET /api/internal/serv/command/51/gogogo/bm?mode=2&verb=git-receive-pack for 127.0.0.1
2020/05/18 15:27:07 ...s/context/context.go:330:func1() [D] Session ID: 74348dc5eca696d5
2020/05/18 15:27:07 ...s/context/context.go:331:func1() [D] CSRF Token: IhkfEPBEwuQasSb5zYnlOV89dO06MTU4OTc4NjgyNzMwNjAzNzY0Ng
2020/05/18 15:27:07 ...ters/private/serv.go:363:ServCommand() [D] Serv Results:
    IsWiki: false
    IsDeployKey: false
    KeyID: 51   KeyName: hi@test.com
    UserName: test
    UserID: 1
    OwnerName: gogogo
    RepoName: bm
    RepoID: 10
2020/05/18 15:27:07 Completed GET /api/internal/serv/command/51/gogogo/bm?mode=2&verb=git-receive-pack 200 OK in 235.573967ms
2020/05/18 15:27:09 Started POST /api/internal/ssh/51/update/10 for 127.0.0.1
2020/05/18 15:27:09 ...s/context/context.go:330:func1() [D] Session ID: bf963d170e8f9669
2020/05/18 15:27:09 ...s/context/context.go:331:func1() [D] CSRF Token: 5LbJnsbiYGVCJCqisKyWgcLdKNU6MTU4OTc4NjgyOTMwNzc0NzU4MA
2020/05/18 15:27:09 Completed POST /api/internal/ssh/51/update/10 200 OK in 129.844367ms
zeripath commented 4 years ago

So you never get a /api/internal/hook/pre-receive ? (In that there is definitely not anything more logged?)

Then you need to check the hooks directory - because it seems like they're not working.

Is it possible that you don't have bash installed? Have you run the resynchronize hooks function? etc. What do the contents of the hooks directory look like for that repository?

hisune commented 4 years ago

it looks like never request /api/internal/hook/pre-receive the repo hooks dir:

[hooks]# ll
total 68
-rwx------ 1 git git  452 Jan 29  2018 applypatch-msg.sample
-rwx------ 1 git git  896 Jan 29  2018 commit-msg.sample
-rwx------ 1 git git  160 Jan 29  2018 post-commit.sample
-rwxrwxr-x 1 git git  324 May 18 15:24 post-receive
drwx------ 2 git git 4096 May 18 15:24 post-receive.d
-rwx------ 1 git git  548 Jan 29  2018 post-receive.sample
-rwx------ 1 git git  189 Jan 29  2018 post-update.sample
-rwx------ 1 git git  398 Jan 29  2018 pre-applypatch.sample
-rwx------ 1 git git 1578 Jan 29  2018 pre-commit.sample
-rwx------ 1 git git 1239 Jan 29  2018 prepare-commit-msg.sample
-rwx------ 1 git git 4951 Jan 29  2018 pre-rebase.sample
-rwxrwxr-x 1 git git  324 May 18 15:24 pre-receive
drwx------ 2 git git 4096 May 18 15:24 pre-receive.d
-rwxrwxr-x 1 git git  304 May 18 15:24 update
drwx------ 2 git git 4096 May 18 15:24 update.d
-rwx------ 1 git git 3611 Jan 29  2018 update.sample

i have run Resynchronize pre-receive, update and post-receive hooks of all repositories. many times in admin panel.

bash is installed

cant push with ssh after I upgraded the gitea version to 1.11.5, and pull is ok

fortunately i can push with https

app.ini if any help

APP_NAME = xxx
RUN_USER = git
RUN_MODE = prod

[database]
DB_TYPE            = mysql
HOST               = 127.0.0.1:3306
NAME               = xxx
USER               = xxx
PASSWD             = xxx
SSL_MODE           = disable
PATH               = /home/git/data/gogs.db
MAX_IDLE_CONNS     = 5
CONN_MAX_LIFE_TIME = 300
LOG_SQL            = false

[repository]
ROOT            = /home/git/gogs-repositories
FORCE_PRIVATE   = true
DEFAULT_PRIVATE = private

[ui]
ISSUE_PAGING_NUM       = 15
DEFAULT_SHOW_FULL_NAME = true
THEMES                 = gitea,arc-green

[server]
DOMAIN                  = git.xxx
HTTP_PORT               = 3000
ROOT_URL                = https://git.xxx/
LOCAL_ROOT_URL          = http://localhost:3000/
DISABLE_SSH             = false
SSH_PORT                = 22
START_SSH_SERVER        = true
BUILTIN_SSH_SERVER_USER = git

[mailer]
ENABLED = true
HOST    = XXX
FROM    = XXX
USER    = XXX
PASSWD  = XXX

[service]
REGISTER_EMAIL_CONFIRM = true
ENABLE_NOTIFY_MAIL     = true
DISABLE_REGISTRATION   = true
ENABLE_CAPTCHA         = false
REQUIRE_SIGNIN_VIEW    = true

[picture]
DISABLE_GRAVATAR        = false
ENABLE_FEDERATED_AVATAR = false

[session]
PROVIDER = file

[log]
MODE      = console 
LEVEL     = Debug
ROOT_PATH = /home/git/gogs/log
REDIRECT_MACARON_LOG = true
MACARON = console
ROUTER = console
XORM = console

[security]
INSTALL_LOCK   = true
SECRET_KEY     = XXX
INTERNAL_TOKEN = XXX

[oauth2]
JWT_SECRET = XXX

[time]
FORMAT              = 2020/01/02 15:04:05
DEFAULT_UI_LOCATION = Asia/Shanghai

[other]
SHOW_FOOTER_VERSION = false

[attachment]
ALLOWED_TYPES = */*
MAX_SIZE      = 50
MAX_FILES     = 5
zeripath commented 4 years ago

and what does pre-receive.d/ look like?

Are you sure that when you log in through ssh that you're running as the git user? I note that the pre-receive.d, update.d and post-receive.d directories are all mode 0700 - is that definitely correct? what happens if you make them mode 755?

hisune commented 4 years ago

i set all git dir to 755, the problem still exists, i sure gitea is runing as git user:

[git]# ps aux | grep gitea
git      25894 12.8 13.4 389700 136748 pts/1   Sl+  17:13   0:00 ./gitea web
root     25916  0.0  0.1 103388  1084 pts/4    S+   17:13   0:00 grep gitea

the pre-receive.d

[pre-receive.d]# ll
total 8
-rwxr-xr-x 1 git git 108 May 18 15:24 gitea
-rwxr-xr-x 1 git git 105 May 18 15:23 pre-receive2

the pre-receive2 is backup of pre-receive, i deleted pre-receive, and run Resynchronize pre-receive, update and post-receive hooks of all repositories., but pre-receive is not created, its the problem?

zeripath commented 4 years ago

what is in pre-receive2 and gitea? You almost certainly only need the gitea one.

hisune commented 4 years ago

the pre-receive2 is the backup of pre-receive, i made a backup when delete pre-receive

zeripath commented 4 years ago

it will be ran... That could easily be what is causing the problem. What are the contents of pre-receive.d/gitea and pre-receive.d/pre-receive2?

hisune commented 4 years ago

gitea

]# cat /home/git/gogs-repositories/gogogo/bm.git/hooks/pre-receive.d/gitea
#!/usr/bin/env bash
"/home/git/gitea/gitea" hook --config='/home/git/gitea/custom/conf/app.ini' pre-receive

pre-receive2

]# cat /home/git/gogs-repositories/gogogo/bm.git/hooks/pre-receive.d/pre-receive2
#!/usr/bin/env bash
"/home/git/gogs/gogs" hook --config='/home/git/gogs/custom/conf/app.ini' pre-receive
zeripath commented 4 years ago

Delete pre-receive2 - and any other hooks that reference "/home/git/gogs/gogs"

There's probably update and post-receive hooks that are similar and you will need to look at the rest of your repositories to check if they too have leftover hooks from gogs.

hisune commented 4 years ago

not work after delete pre-receive2, i'll use https instead of use ssh

zeripath commented 4 years ago

you need to delete the old gogs hooks in update.d/ and post-receive.d/ too and for all of the repositories that were known to Gogs.

hisune commented 4 years ago

i deleted all old hook:

rm -f */*.git/hooks/post-receive.d/post-receive
rm -f */*.git/hooks/post-receive.d/post-receive2
rm -f */*.git/hooks/pre-receive.d/pre-receive
rm -f */*.git/hooks/pre-receive.d/pre-receive2

and run Resynchronize pre-receive, update and post-receive hooks of all repositories. still not work, i'll use https, thx

`

zeripath commented 4 years ago

and update.d

hisune commented 4 years ago

also not work

lafriks commented 4 years ago

Did new pre-receive script was generated?

hisune commented 4 years ago

not generated, only gitea

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.

zeripath commented 4 years ago

I bet this is a duplicate of #9792 which is an issue with systemd permissions issue in hooks. Therefore I'm going to close this.