-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Push to create repo #8419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Push to create repo #8419
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
ee8a2de
Refactor
jolheiser 53ffb2e
Add push-create to SSH serv
jolheiser f1e48e2
Cannot push for another user unless admin
jolheiser c4cb271
Get owner in case admin pushes for another user
jolheiser d47ff51
Merge branch 'master' into push_create_repo
jolheiser 3d9fb5e
Set new repo ID in result
jolheiser c2c8770
Merge branch 'push_create_repo' of https://github.com/jolheiser/gitea…
jolheiser e69ee23
Update to service and use new org perms
jolheiser 00ab55d
Move pushCreateRepo to services
jolheiser 190accd
Merge branch 'master' into push_create_repo
jolheiser f0132fd
Merge branch 'master' into push_create_repo
jolheiser 7632782
Merge branch 'master' into push_create_repo
jolheiser 74b4196
Fix import order
jolheiser 81935b9
Changes for @guillep2k
jolheiser 7ffcd4e
Merge branch 'master' into push_create_repo
jolheiser ee04bed
Merge branch 'master' into push_create_repo
sapk b5a09ca
Merge branch 'master' into push_create_repo
lunny c6a623d
Merge branch 'master' into push_create_repo
jolheiser 5cbe5d8
Merge branch 'master' into push_create_repo
lunny 6ca0f8d
Merge branch 'master' into push_create_repo
jolheiser 9f696ab
Merge branch 'master' into push_create_repo
jolheiser File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,6 +75,8 @@ func testGit(t *testing.T, u *url.URL) { | |
rawTest(t, &forkedUserCtx, little, big, littleLFS, bigLFS) | ||
mediaTest(t, &forkedUserCtx, little, big, littleLFS, bigLFS) | ||
}) | ||
|
||
t.Run("PushCreate", doPushCreate(httpContext, u)) | ||
}) | ||
t.Run("SSH", func(t *testing.T) { | ||
defer PrintCurrentTest(t)() | ||
|
@@ -113,6 +115,8 @@ func testGit(t *testing.T, u *url.URL) { | |
rawTest(t, &forkedUserCtx, little, big, littleLFS, bigLFS) | ||
mediaTest(t, &forkedUserCtx, little, big, littleLFS, bigLFS) | ||
}) | ||
|
||
t.Run("PushCreate", doPushCreate(sshContext, sshURL)) | ||
}) | ||
}) | ||
} | ||
|
@@ -408,3 +412,57 @@ func doMergeFork(ctx, baseCtx APITestContext, baseBranch, headBranch string) fun | |
|
||
} | ||
} | ||
|
||
func doPushCreate(ctx APITestContext, u *url.URL) func(t *testing.T) { | ||
return func(t *testing.T) { | ||
defer PrintCurrentTest(t)() | ||
ctx.Reponame = fmt.Sprintf("repo-tmp-push-create-%s", u.Scheme) | ||
u.Path = ctx.GitPath() | ||
|
||
tmpDir, err := ioutil.TempDir("", ctx.Reponame) | ||
assert.NoError(t, err) | ||
|
||
err = git.InitRepository(tmpDir, false) | ||
assert.NoError(t, err) | ||
|
||
_, err = os.Create(filepath.Join(tmpDir, "test.txt")) | ||
assert.NoError(t, err) | ||
|
||
err = git.AddChanges(tmpDir, true) | ||
assert.NoError(t, err) | ||
|
||
err = git.CommitChanges(tmpDir, git.CommitChangesOptions{ | ||
Committer: &git.Signature{ | ||
Email: "[email protected]", | ||
Name: "User Two", | ||
When: time.Now(), | ||
}, | ||
Author: &git.Signature{ | ||
Email: "[email protected]", | ||
Name: "User Two", | ||
When: time.Now(), | ||
}, | ||
Message: fmt.Sprintf("Testing push create @ %v", time.Now()), | ||
}) | ||
assert.NoError(t, err) | ||
|
||
_, err = git.NewCommand("remote", "add", "origin", u.String()).RunInDir(tmpDir) | ||
assert.NoError(t, err) | ||
|
||
// Push to create disabled | ||
setting.Repository.EnablePushCreateUser = false | ||
_, err = git.NewCommand("push", "origin", "master").RunInDir(tmpDir) | ||
assert.Error(t, err) | ||
|
||
// Push to create enabled | ||
setting.Repository.EnablePushCreateUser = true | ||
_, err = git.NewCommand("push", "origin", "master").RunInDir(tmpDir) | ||
assert.NoError(t, err) | ||
|
||
// Fetch repo from database | ||
repo, err := models.GetRepositoryByOwnerAndName(ctx.Username, ctx.Reponame) | ||
assert.NoError(t, err) | ||
assert.False(t, repo.IsEmpty) | ||
assert.True(t, repo.IsPrivate) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.