summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Botelho <tiagonbotelho@hotmail.com>2018-01-31 13:52:46 +0000
committerTiago Botelho <tiagonbotelho@hotmail.com>2018-02-06 13:35:35 +0000
commit839829a7786dd163eccb470bf251211bfb90bd72 (patch)
treea30dd2d54dc1b20d9b5e5130b7f4bc5ce44c2723
parentdc229c076cdc0ef6e7f3f74f6e462c22880ff08c (diff)
downloadgitlab-ce-839829a7786dd163eccb470bf251211bfb90bd72.tar.gz
Adds documentation for the feature
-rw-r--r--doc/gitlab-basics/create-project.md38
-rw-r--r--lib/gitlab/git_access.rb8
2 files changed, 44 insertions, 2 deletions
diff --git a/doc/gitlab-basics/create-project.md b/doc/gitlab-basics/create-project.md
index e18711f3392..d491d676884 100644
--- a/doc/gitlab-basics/create-project.md
+++ b/doc/gitlab-basics/create-project.md
@@ -33,5 +33,43 @@
1. Click **Create project**.
+## Push to create a new project
+
+> [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/issues/26388) in GitLab 10.5.
+
+When you create a new repo locally, instead of going to GitLab to manually
+create a new project and then push the repo, you can directly push it to
+GitLab to create the new project, all without leaving your terminal. That
+will automatically create a new project under a GitLab namespace that you have access to
+with its visibility set to private by default (you can later change it).
+
+This can be done by using either SSH or HTTP:
+
+```
+## Git push using SSH
+git push git@gitlab.com:namespace/nonexistent-project.git branch_name
+
+## Git push using HTTP
+git push https://gitlab.com/namespace/nonexistent-project.git branch_name
+```
+
+Once the push finishes successfully, a remote message will indicate
+the command to set the remote and the URL to the new project:
+
+```
+remote:
+remote: The private project namespace/nonexistent-project was created.
+remote:
+remote: To configure the remote, run:
+remote: git remote add origin https://gitlab.com/namespace/nonexistent-project.git
+remote:
+remote: To view the project, visit:
+remote: https://gitlab.com/namespace/nonexistent-project
+remote:
+```
+
+If the project name is already in use, your push will be rejected
+to prevent accidental overwriting the existing project.
+
[import it]: ../workflow/importing/README.md
[reserved]: ../user/reserved_names.md
diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb
index 3d07e112e2b..84299dd5790 100644
--- a/lib/gitlab/git_access.rb
+++ b/lib/gitlab/git_access.rb
@@ -2,6 +2,8 @@
# class return an instance of `GitlabAccessStatus`
module Gitlab
class GitAccess
+ include Gitlab::Utils::StrongMemoize
+
UnauthorizedError = Class.new(StandardError)
NotFoundError = Class.new(StandardError)
ProjectCreationError = Class.new(StandardError)
@@ -239,9 +241,11 @@ module Gitlab
end
def can_create_project_in_namespace?(cmd)
- return false unless push?(cmd) && target_namespace && project.blank?
+ strong_memoize(:can_create_project_in_namespace) do
+ return false unless push?(cmd) && target_namespace && project.blank?
- user.can?(:create_projects, target_namespace)
+ user.can?(:create_projects, target_namespace)
+ end
end
def http?