-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: jolheiser <[email protected]>
- Loading branch information
Showing
5 changed files
with
132 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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 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 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)) | ||
}) | ||
}) | ||
} | ||
|
@@ -407,3 +411,51 @@ 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) | ||
} | ||
} |
This file contains 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 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