Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
See what's new at GitLab
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
IGitt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
34
Issues
34
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
10
Merge Requests
10
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gitmate
open-source
IGitt
Commits
0be225aa
Verified
Commit
0be225aa
authored
Apr 02, 2018
by
Naveen Kumar Sangi
👽
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Repository.create: Add method to create repository
parent
36f212bb
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
543 additions
and
10 deletions
+543
-10
IGitt/GitHub/GitHubRepository.py
IGitt/GitHub/GitHubRepository.py
+94
-1
IGitt/GitLab/GitLabRepository.py
IGitt/GitLab/GitLabRepository.py
+142
-1
IGitt/Interfaces/Repository.py
IGitt/Interfaces/Repository.py
+64
-5
tests/GitHub/cassettes/GitHubRepositoryTest.test_repo_create_and_delete.yaml
...tes/GitHubRepositoryTest.test_repo_create_and_delete.yaml
+128
-0
tests/GitHub/test_github_repository.py
tests/GitHub/test_github_repository.py
+6
-3
tests/GitLab/cassettes/GitLabRepositoryTest.test_repo_create_and_delete.yaml
...tes/GitLabRepositoryTest.test_repo_create_and_delete.yaml
+102
-0
tests/GitLab/test_gitlab_repository.py
tests/GitLab/test_gitlab_repository.py
+7
-0
No files found.
IGitt/GitHub/GitHubRepository.py
View file @
0be225aa
...
...
@@ -14,6 +14,7 @@ from IGitt.GitHub import GitHubInstallationToken
from
IGitt.GitHub.GitHubIssue
import
GitHubIssue
from
IGitt.GitHub.GitHubOrganization
import
GitHubOrganization
from
IGitt.Interfaces
import
get
,
post
,
put
,
delete
from
IGitt.Interfaces
import
BasicAuthorizationToken
from
IGitt.Interfaces
import
AccessLevel
from
IGitt.Interfaces
import
IssueStates
from
IGitt.Interfaces
import
MergeRequestStates
...
...
@@ -155,7 +156,7 @@ class GitHubRepository(GitHubMixin, Repository):
return
{
label
[
'name'
]
for
label
in
get
(
self
.
_token
,
self
.
url
+
'/labels'
)}
def
create_label
(
self
,
name
:
str
,
color
:
str
):
def
create_label
(
self
,
name
:
str
,
color
:
str
=
''
,
**
kwargs
):
"""
Creates a new label with the given color. For an example,
see delete_label.
...
...
@@ -553,3 +554,95 @@ class GitHubRepository(GitHubMixin, Repository):
if
self
.
data
[
'fork'
]
is
True
:
return
GitHubRepository
.
from_data
(
self
.
data
[
'parent'
],
self
.
_token
,
self
.
data
[
'parent'
][
'id'
])
@
staticmethod
def
create
(
token
:
Union
[
GitHubToken
,
BasicAuthorizationToken
,
GitHubInstallationToken
],
name
:
str
,
org_name
:
Optional
[
str
]
=
None
,
description
:
Optional
[
str
]
=
None
,
homepage
:
Optional
[
str
]
=
None
,
visibility
:
str
=
'public'
,
has_issues
:
bool
=
True
,
has_projects
:
bool
=
True
,
has_wiki
:
bool
=
True
,
team_id
:
Optional
[
int
]
=
None
,
auto_init
:
bool
=
False
,
gitignore_template
:
Optional
[
str
]
=
None
,
license_template
:
Optional
[
str
]
=
None
,
allow_squash_merge
:
bool
=
True
,
allow_merge_commit
:
bool
=
True
,
allow_rebase_merge
:
bool
=
True
,
**
kwargs
):
"""
Creates a new repository and returns associated GitHubRepository
instance.
:param token:
The token to be used for authentication.
:param name:
The name of the repository.
:param org_name:
The name of the organization this repository is to be created in.
Pass ``None`` if it is a user repository.
:param description:
A short description of the repository.
:param homepage:
A URL with more information about the repository.
:param visibility:
Either ``private`` to create a private repository or ``public`` to
create a public one.
:param has_issues:
Either ``True`` to enable issues for this repository or ``False``
to disable them.
:param has_projects:
Either ``True`` to enable projects for this repository or ``False``
to disable them.
Note: If you're creating a repository in an organization that has
disabled repository projects, the default is false, and if you pass
true, the API returns an error.
:param has_wiki:
Either ``True`` to enable a wiki for this repository or ``False``
to disable it.
:param team_id:
The id of the team that will be granted access to this repository.
This is only valid when creating a repository in an organization.
:param auto_init:
Pass ``True`` to create an initial commit with empty README.
:param gitignore_template:
Desired language or platform .gitignore template to apply.
Use the name of the template without the extension. For example,
"Haskell".
Reference: https://github.com/github/gitignore
:param license_template:
Choose an open source license template that best suits your needs,
and then use the license keyword as the license_template string.
For example, "mit" or "mpl-2.0".
Reference: https://help.github.com/articles/licensing-a-repository/#searching-github-by-license-type
:param allow_squash_merge:
Pass ``True`` to allow squash merging pull requests.
:param allow_merge_commit:
Pass ``True`` to allow merging pull requests with a merge commit.
:param allow_rebase_merge:
Pass ``True`` to allow rebase-merging pull requests.
"""
data
=
eliminate_none
({
'name'
:
name
,
'description'
:
description
,
'homepage'
:
homepage
,
'private'
:
True
if
visibility
==
'private'
else
False
,
'has_issues'
:
has_issues
,
'has_projects'
:
has_projects
,
'has_wiki'
:
has_wiki
,
'team_id'
:
team_id
,
'auto_init'
:
auto_init
,
'gitignore_template'
:
gitignore_template
,
'license_template'
:
license_template
,
'allow_squash_merge'
:
allow_squash_merge
,
'allow_merge_commit'
:
allow_merge_commit
,
'allow_rebase_merge'
:
allow_rebase_merge
})
url
=
'/orgs/{}/repos'
.
format
(
org_name
)
if
org_name
else
'/user/repos'
repo
=
post
(
token
,
GitHubRepository
.
absolute_url
(
url
),
data
)
return
GitHubRepository
.
from_data
(
repo
,
token
,
repo
[
'id'
])
IGitt/GitLab/GitLabRepository.py
View file @
0be225aa
...
...
@@ -2,6 +2,7 @@
Contains the GitLab Repository implementation.
"""
from
datetime
import
datetime
from
typing
import
List
from
typing
import
Optional
from
typing
import
Set
from
typing
import
Union
...
...
@@ -13,6 +14,7 @@ from IGitt.GitLab import GitLabOAuthToken, GitLabPrivateToken
from
IGitt.GitLab.GitLabIssue
import
GitLabIssue
from
IGitt.GitLab.GitLabOrganization
import
GitLabOrganization
from
IGitt.Interfaces
import
delete
,
get
,
post
from
IGitt.Interfaces
import
BasicAuthorizationToken
from
IGitt.Interfaces
import
AccessLevel
from
IGitt.Interfaces
import
IssueStates
from
IGitt.Interfaces
import
MergeRequestStates
...
...
@@ -174,7 +176,7 @@ class GitLabRepository(GitLabMixin, Repository):
return
{
label
[
'name'
]
for
label
in
get
(
self
.
_token
,
self
.
url
+
'/labels'
)}
def
create_label
(
self
,
name
:
str
,
color
:
str
):
def
create_label
(
self
,
name
:
str
,
color
:
str
=
''
,
**
kwargs
):
"""
Creates a new label with the given color. For an example,
see delete_label.
...
...
@@ -561,3 +563,142 @@ class GitLabRepository(GitLabMixin, Repository):
self
.
data
[
'forked_from_project'
][
'id'
])
except
KeyError
:
return
None
@
staticmethod
def
create
(
token
:
Union
[
BasicAuthorizationToken
,
GitLabPrivateToken
,
GitLabOAuthToken
],
name
:
str
,
path
:
Optional
[
str
]
=
None
,
visibility
:
str
=
'public'
,
namespace_id
:
Optional
[
int
]
=
None
,
default_branch
:
Optional
[
str
]
=
'master'
,
description
:
Optional
[
str
]
=
None
,
has_issues
:
bool
=
True
,
has_merge_requests
:
bool
=
True
,
has_jobs
:
bool
=
True
,
has_wiki
:
bool
=
True
,
has_snippets
:
bool
=
True
,
has_container_registry
:
bool
=
True
,
has_shared_runners
:
bool
=
True
,
has_lfs
:
bool
=
False
,
resolve_outdated_diff_discussions
:
bool
=
False
,
import_url
:
Optional
[
str
]
=
None
,
public_jobs
:
bool
=
False
,
only_allow_merge_if_pipeline_succeeds
:
bool
=
False
,
only_allow_merge_if_all_discussions_are_resolved
:
bool
=
False
,
allow_request_access
:
bool
=
True
,
allow_printing_merge_request_link
:
bool
=
True
,
tag_list
:
Optional
[
List
[
str
]]
=
None
,
avatar
:
Optional
[
object
]
=
None
,
ci_config_path
:
Optional
[
str
]
=
None
,
repository_storage
:
Optional
[
str
]
=
None
,
approvals_before_merge
:
Optional
[
int
]
=
None
,
**
kwargs
):
"""
Creates a new repository and returns the associated GitLabRepository
instance.
:param token:
The credentials to be used for authentication.
:param name:
The name of the new project. Equals ``path`` if not provided.
:param path:
Repository name for new project. Generated based on name if not
provided (generated lowercased with dashes).
:param visibility:
Either of ``private``, ``public`` or ``internal``.
Reference: https://docs.gitlab.com/ee/api/projects.html#project-visibility-level
:param namespace_id:
Namespace for the new project (defaults to the current user's
namespace)
:param default_branch:
The default branch to be used.
:param description:
A short description of the repository.
:param has_issues:
Either ``True`` to enable issues for this project or ``False`` to
disable them.
:param has_merge_requests:
Either ``True`` to enable merge requests for this project or
``False`` to disable them.
:param has_jobs:
Either ``True`` to enable jobs for this project or ``False`` to
disable them.
:param has_wiki:
Either ``True`` to enable wiki for this project or ``False`` to
disable it.
:param has_snippets:
Either ``True`` to enable snippets for this project or ``False`` to
disable them.
:param has_container_registry:
Either ``True`` to enable container registry or ``False`` to
disable it.
:param has_lfs:
Either ``True`` to enable Git Large File Sharing or ``False`` to
disable it.
:param resolve_outdated_diff_discussions:
Either ``True`` to automatically resolve merge request diff
discussions on lines changed with a push of ``False`` to disable
it.
:param import_url:
URL to import repository from.
:param public_jobs:
If ``True``, jobs can be viewed by non-project-members.
:param only_allow_merge_if_pipeline_succeeds:
Set whether merge requests can only be merged with successful jobs.
:param only_allow_merge_if_all_discussions_are_resolved:
Set whether merge requests can only be merged when all the
discussions are resolved.
:param allow_request_access:
Allow users to request member access.
:param allow_printing_merge_request_link:
Show link to create/view merge request when pushing from the
command line.
:param tag_list:
The list of tags for a project that should be finally assigned to a
project.
:param avatar:
Image file for avatar of the project (base64 encoded png).
:param ci_config_path:
The path to CI config file.
:param repository_storage:
Which storage shard the repository is on. Available only to admins.
:param approvals_before_merge:
How many approvers should approve merge request by default before
allowing it to be merged.
"""
data
=
eliminate_none
({
'name'
:
name
,
'path'
:
path
,
'visibility'
:
visibility
,
'namespace_id'
:
namespace_id
,
'default_branch'
:
default_branch
,
'description'
:
description
,
'has_issues'
:
has_issues
,
'has_merge_requests'
:
has_merge_requests
,
'has_jobs'
:
has_jobs
,
'has_wiki'
:
has_wiki
,
'has_snippets'
:
has_snippets
,
'has_container_registry'
:
has_container_registry
,
'has_shared_runners'
:
has_shared_runners
,
'has_lfs'
:
has_lfs
,
'resolve_outdated_diff_discussions'
:
resolve_outdated_diff_discussions
,
'import_url'
:
import_url
,
'public_jobs'
:
public_jobs
,
'only_allow_merge_if_pipeline_succeeds'
:
only_allow_merge_if_pipeline_succeeds
,
'only_allow_merge_if_all_discussions_are_resolved'
:
only_allow_merge_if_all_discussions_are_resolved
,
'allow_request_access'
:
allow_request_access
,
'allow_printing_merge_request_link'
:
allow_printing_merge_request_link
,
'tag_list'
:
tag_list
,
'avatar'
:
avatar
,
'ci_config_path'
:
ci_config_path
,
'repository_storage'
:
repository_storage
,
'approvals_before_merge'
:
approvals_before_merge
})
repo
=
post
(
token
,
GitLabRepository
.
absolute_url
(
'/projects'
),
data
)
return
GitLabRepository
.
from_data
(
repo
,
token
,
repo
[
'id'
])
IGitt/Interfaces/Repository.py
View file @
0be225aa
...
...
@@ -6,6 +6,7 @@ from datetime import datetime
from
enum
import
Enum
from
os
import
chdir
,
getcwd
from
tempfile
import
mkdtemp
from
typing
import
List
from
typing
import
Optional
from
typing
import
Set
from
typing
import
Union
...
...
@@ -16,6 +17,7 @@ from IGitt.Interfaces import AccessLevel
from
IGitt.Interfaces
import
IGittObject
from
IGitt.Interfaces
import
MergeRequestStates
from
IGitt.Interfaces
import
IssueStates
from
IGitt.Interfaces
import
Token
class
WebhookEvents
(
Enum
):
...
...
@@ -108,14 +110,26 @@ class Repository(IGittObject):
"""
raise
NotImplementedError
def
create_label
(
self
,
name
:
str
,
color
:
str
):
def
create_label
(
self
,
name
:
str
,
color
:
Optional
[
str
]
=
None
,
description
:
Optional
[
str
]
=
None
,
label_type
:
Optional
[
str
]
=
None
):
"""
Creates a new label.
:param name: The name of the label to create.
:param color: A HTML color value with a leading #.
:raises ElementAlreadyExistsError: If the label name already exists.
:raises RuntimeError: If something goes wrong (network, auth...).
:param name:
The name of the label to create.
:param color:
A HTML color value with a leading #.
:param description:
The description of the label to be created.
:param label_type:
The type of the label to be created.
:raises ElementAlreadyExistsError:
If the label name already exists.
:raises RuntimeError:
If something goes wrong (network, auth...).
"""
raise
NotImplementedError
...
...
@@ -304,3 +318,48 @@ class Repository(IGittObject):
Returns `None` if it has no fork relationship.
"""
raise
NotImplementedError
@
staticmethod
def
create
(
token
:
Token
,
name
:
str
,
path
:
Optional
[
str
]
=
None
,
namespace_id
:
Optional
[
int
]
=
None
,
default_branch
:
Optional
[
str
]
=
'master'
,
resolve_outdated_diff_discussions
:
bool
=
False
,
import_url
:
Optional
[
str
]
=
None
,
public_jobs
:
bool
=
False
,
tag_list
:
Optional
[
List
[
str
]]
=
None
,
avatar
:
Optional
[
object
]
=
None
,
ci_config_path
:
Optional
[
str
]
=
None
,
repository_storage
:
Optional
[
str
]
=
None
,
approvals_before_merge
:
Optional
[
int
]
=
None
,
org_name
:
Optional
[
str
]
=
None
,
description
:
Optional
[
str
]
=
None
,
homepage
:
Optional
[
str
]
=
None
,
visibility
:
str
=
'public'
,
has_issues
:
bool
=
True
,
has_merge_requests
:
bool
=
True
,
has_jobs
:
bool
=
True
,
has_snippets
:
bool
=
True
,
has_projects
:
bool
=
True
,
has_wiki
:
bool
=
True
,
has_container_registry
:
bool
=
True
,
has_shared_runners
:
bool
=
True
,
has_lfs
:
bool
=
False
,
team_id
:
Optional
[
int
]
=
None
,
auto_init
:
bool
=
False
,
gitignore_template
:
Optional
[
str
]
=
None
,
license_template
:
Optional
[
str
]
=
None
,
allow_request_access
:
bool
=
True
,
allow_squash_merge
:
bool
=
True
,
allow_merge_commit
:
bool
=
True
,
allow_rebase_merge
:
bool
=
True
,
allow_printing_merge_request_link
:
bool
=
True
,
only_allow_merge_if_pipeline_succeeds
:
bool
=
False
,
project_type
:
Optional
[
str
]
=
None
,
project_key
:
Optional
[
str
]
=
None
,
project_lead
:
Optional
[
str
]
=
None
):
"""
Creates a new repository and returns it.
"""
raise
NotImplementedError
tests/GitHub/cassettes/GitHubRepositoryTest.test_repo_create_and_delete.yaml
0 → 100644
View file @
0be225aa
interactions
:
-
request
:
body
:
'
{"name":
"test-repo",
"private":
false,
"has_issues":
true,
"has_projects":
true,
"has_wiki":
true,
"auto_init":
false,
"allow_squash_merge":
true,
"allow_merge_commit":
true,
"allow_rebase_merge":
true}'
headers
:
Accept
:
[
'
*/*'
]
Accept-Encoding
:
[
'
gzip,
deflate'
]
Connection
:
[
keep-alive
]
Content-Length
:
[
'
203'
]
Content-Type
:
[
application/json
]
If-None-Match
:
[
W/"f38dab70971d8238cf82aae59dcc05e6"
]
User-Agent
:
[
IGitt
]
method
:
POST
uri
:
https://api.github.com/user/repos
response
:
body
:
{
string
:
'
{"id":127677241,"name":"test-repo","full_name":"nkprince007/test-repo","owner":{"login":"nkprince007","id":17202890,"avatar_url":"https://avatars3.githubusercontent.com/u/17202890?v=4","gravatar_id":"","url":"https://api.github.com/users/nkprince007","html_url":"https://github.com/nkprince007","followers_url":"https://api.github.com/users/nkprince007/followers","following_url":"https://api.github.com/users/nkprince007/following{/other_user}","gists_url":"https://api.github.com/users/nkprince007/gists{/gist_id}","starred_url":"https://api.github.com/users/nkprince007/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nkprince007/subscriptions","organizations_url":"https://api.github.com/users/nkprince007/orgs","repos_url":"https://api.github.com/users/nkprince007/repos","events_url":"https://api.github.com/users/nkprince007/events{/privacy}","received_events_url":"https://api.github.com/users/nkprince007/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nkprince007/test-repo","description":null,"fork":false,"url":"https://api.github.com/repos/nkprince007/test-repo","forks_url":"https://api.github.com/repos/nkprince007/test-repo/forks","keys_url":"https://api.github.com/repos/nkprince007/test-repo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nkprince007/test-repo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nkprince007/test-repo/teams","hooks_url":"https://api.github.com/repos/nkprince007/test-repo/hooks","issue_events_url":"https://api.github.com/repos/nkprince007/test-repo/issues/events{/number}","events_url":"https://api.github.com/repos/nkprince007/test-repo/events","assignees_url":"https://api.github.com/repos/nkprince007/test-repo/assignees{/user}","branches_url":"https://api.github.com/repos/nkprince007/test-repo/branches{/branch}","tags_url":"https://api.github.com/repos/nkprince007/test-repo/tags","blobs_url":"https://api.github.com/repos/nkprince007/test-repo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nkprince007/test-repo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nkprince007/test-repo/git/refs{/sha}","trees_url":"https://api.github.com/repos/nkprince007/test-repo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nkprince007/test-repo/statuses/{sha}","languages_url":"https://api.github.com/repos/nkprince007/test-repo/languages","stargazers_url":"https://api.github.com/repos/nkprince007/test-repo/stargazers","contributors_url":"https://api.github.com/repos/nkprince007/test-repo/contributors","subscribers_url":"https://api.github.com/repos/nkprince007/test-repo/subscribers","subscription_url":"https://api.github.com/repos/nkprince007/test-repo/subscription","commits_url":"https://api.github.com/repos/nkprince007/test-repo/commits{/sha}","git_commits_url":"https://api.github.com/repos/nkprince007/test-repo/git/commits{/sha}","comments_url":"https://api.github.com/repos/nkprince007/test-repo/comments{/number}","issue_comment_url":"https://api.github.com/repos/nkprince007/test-repo/issues/comments{/number}","contents_url":"https://api.github.com/repos/nkprince007/test-repo/contents/{+path}","compare_url":"https://api.github.com/repos/nkprince007/test-repo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nkprince007/test-repo/merges","archive_url":"https://api.github.com/repos/nkprince007/test-repo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nkprince007/test-repo/downloads","issues_url":"https://api.github.com/repos/nkprince007/test-repo/issues{/number}","pulls_url":"https://api.github.com/repos/nkprince007/test-repo/pulls{/number}","milestones_url":"https://api.github.com/repos/nkprince007/test-repo/milestones{/number}","notifications_url":"https://api.github.com/repos/nkprince007/test-repo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nkprince007/test-repo/labels{/name}","releases_url":"https://api.github.com/repos/nkprince007/test-repo/releases{/id}","deployments_url":"https://api.github.com/repos/nkprince007/test-repo/deployments","created_at":"2018-04-01T22:41:13Z","updated_at":"2018-04-01T22:41:13Z","pushed_at":"2018-04-01T22:41:14Z","git_url":"git://github.com/nkprince007/test-repo.git","ssh_url":"git@github.com:nkprince007/test-repo.git","clone_url":"https://github.com/nkprince007/test-repo.git","svn_url":"https://github.com/nkprince007/test-repo","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master","permissions":{"admin":true,"push":true,"pull":true},"allow_squash_merge":true,"allow_merge_commit":true,"allow_rebase_merge":true,"network_count":0,"subscribers_count":0}'
}
headers
:
Access-Control-Allow-Origin
:
[
'
*'
]
Access-Control-Expose-Headers
:
[
'
ETag,
Link,
Retry-After,
X-GitHub-OTP,
X-RateLimit-Limit,
X-RateLimit-Remaining,
X-RateLimit-Reset,
X-OAuth-Scopes,
X-Accepted-OAuth-Scopes,
X-Poll-Interval'
]
Cache-Control
:
[
'
private,
max-age=60,
s-maxage=60'
]
Content-Length
:
[
'
4985'
]
Content-Security-Policy
:
[
default-src 'none'
]
Content-Type
:
[
application/json; charset=utf-8
]
Date
:
[
'
Sun,
01
Apr
2018
22:41:14
GMT'
]
ETag
:
[
'
"ff6ab87d76a953d7214ca5c35db8d349"'
]
Location
:
[
'
https://api.github.com/repos/nkprince007/test-repo'
]
Referrer-Policy
:
[
'
origin-when-cross-origin,
strict-origin-when-cross-origin'
]
Server
:
[
GitHub.com
]
Status
:
[
201 Created
]
Strict-Transport-Security
:
[
max-age=31536000; includeSubdomains; preload
]
Vary
:
[
'
Accept,
Authorization,
Cookie,
X-GitHub-OTP'
]
X-Accepted-OAuth-Scopes
:
[
'
public_repo,
repo'
]
X-Content-Type-Options
:
[
nosniff
]
X-Frame-Options
:
[
deny
]
X-GitHub-Media-Type
:
[
github.v3; format=json
]
X-GitHub-Request-Id
:
[
'
A8F8:41C7:13E7A29:2B2925B:5AC16008'
]
X-OAuth-Scopes
:
[
'
admin:gpg_key,
admin:org,
admin:org_hook,
admin:public_key,
admin:repo_hook,
delete_repo,
gist,
notifications,
repo,
user'
]
X-RateLimit-Limit
:
[
'
5000'
]
X-RateLimit-Remaining
:
[
'
4998'
]
X-RateLimit-Reset
:
[
'
1522626029'
]
X-Runtime-rack
:
[
'
0.736050'
]
X-XSS-Protection
:
[
1; mode=block
]
status
:
{
code
:
201
,
message
:
Created
}
-
request
:
body
:
'
{}'
headers
:
Accept
:
[
'
*/*'
]
Accept-Encoding
:
[
'
gzip,
deflate'
]
Connection
:
[
keep-alive
]
Content-Length
:
[
'
2'
]
Content-Type
:
[
application/json
]
User-Agent
:
[
IGitt
]
method
:
DELETE
uri
:
https://api.github.com/repositories/127677241
response
:
body
:
{
string
:
'
'
}
headers
:
Access-Control-Allow-Origin
:
[
'
*'
]
Access-Control-Expose-Headers
:
[
'
ETag,
Link,
Retry-After,
X-GitHub-OTP,
X-RateLimit-Limit,
X-RateLimit-Remaining,
X-RateLimit-Reset,
X-OAuth-Scopes,
X-Accepted-OAuth-Scopes,
X-Poll-Interval'
]
Content-Security-Policy
:
[
default-src 'none'
]
Content-Type
:
[
application/octet-stream
]
Date
:
[
'
Sun,
01
Apr
2018
22:41:42
GMT'
]
Referrer-Policy
:
[
'
origin-when-cross-origin,
strict-origin-when-cross-origin'
]
Server
:
[
GitHub.com
]
Status
:
[
204 No Content
]
Strict-Transport-Security
:
[
max-age=31536000; includeSubdomains; preload
]
X-Accepted-OAuth-Scopes
:
[
delete_repo
]
X-Content-Type-Options
:
[
nosniff
]
X-Frame-Options
:
[
deny
]
X-GitHub-Media-Type
:
[
github.v3; format=json
]
X-GitHub-Request-Id
:
[
'
8B4A:41C9:328CB4D:5FECE70:5AC16025'
]
X-OAuth-Scopes
:
[
'
admin:gpg_key,
admin:org,
admin:org_hook,
admin:public_key,
admin:repo_hook,
delete_repo,
gist,
notifications,
repo,
user'
]
X-RateLimit-Limit
:
[
'
5000'
]
X-RateLimit-Remaining
:
[
'
4997'
]
X-RateLimit-Reset
:
[
'
1522626029'
]
X-Runtime-rack
:
[
'
0.082856'
]
X-XSS-Protection
:
[
1; mode=block
]
status
:
{
code
:
204
,
message
:
No Content
}
-
request
:
body
:
'
{}'
headers
:
Accept
:
[
'
*/*'
]
Accept-Encoding
:
[
'
gzip,
deflate'
]
Connection
:
[
keep-alive
]
Content-Length
:
[
'
2'
]
Content-Type
:
[
application/json
]
User-Agent
:
[
IGitt
]
method
:
GET
uri
:
https://api.github.com/repositories/127677241?per_page=100
response
:
body
:
string
:
!!binary
|
H4sIAAAAAAAAAw3JMQ6AIAwAwK+Yuho6uPEAR79gEBogAUqgsBj/rrfeA5l6N55Aw8myHDyKgw0c
25GpiJHI5Rot/R9EateIjiYlrtSUjxLGrSxnnDs2qtxx9STwfutuZdhYAAAA
headers
:
Access-Control-Allow-Origin
:
[
'
*'
]
Access-Control-Expose-Headers
:
[
'
ETag,
Link,
Retry-After,
X-GitHub-OTP,
X-RateLimit-Limit,
X-RateLimit-Remaining,
X-RateLimit-Reset,
X-OAuth-Scopes,
X-Accepted-OAuth-Scopes,
X-Poll-Interval'
]
Content-Encoding
:
[
gzip
]
Content-Security-Policy
:
[
default-src 'none'
]
Content-Type
:
[
application/json; charset=utf-8
]
Date
:
[
'
Sun,
01
Apr
2018
22:41:44
GMT'
]
Referrer-Policy
:
[
'
origin-when-cross-origin,
strict-origin-when-cross-origin'
]
Server
:
[
GitHub.com
]
Status
:
[
404 Not Found
]
Strict-Transport-Security
:
[
max-age=31536000; includeSubdomains; preload
]
X-Accepted-OAuth-Scopes
:
[
repo
]
X-Content-Type-Options
:
[
nosniff
]
X-Frame-Options
:
[
deny
]
X-GitHub-Media-Type
:
[
github.v3; format=json
]
X-GitHub-Request-Id
:
[
'
8B60:3CA5:2BA47F8:61B826E:5AC16027'
]
X-OAuth-Scopes
:
[
'
admin:gpg_key,
admin:org,
admin:org_hook,
admin:public_key,
admin:repo_hook,
delete_repo,
gist,
notifications,
repo,
user'
]
X-RateLimit-Limit
:
[
'
5000'
]
X-RateLimit-Remaining
:
[
'
4996'
]
X-RateLimit-Reset
:
[
'
1522626029'
]
X-Runtime-rack
:
[
'
0.024713'
]
X-XSS-Protection
:
[
1; mode=block
]
status
:
{
code
:
404
,
message
:
Not Found
}
version
:
1
tests/GitHub/test_github_repository.py
View file @
0be225aa
...
...
@@ -105,9 +105,12 @@ class GitHubRepositoryTest(IGittTestCase):
def
test_create_fork
(
self
):
self
.
assertIsInstance
(
self
.
fork_repo
.
create_fork
(),
GitHubRepository
)
def
test_repo_delete
(
self
):
fork
=
self
.
fork_repo
.
create_fork
()
self
.
assertIsNone
(
fork
.
delete
())
def
test_repo_create_and_delete
(
self
):
repo
=
GitHubRepository
.
create
(
self
.
token
,
'test-repo'
)
self
.
assertEqual
(
repo
.
full_name
,
'nkprince007/test-repo'
)
self
.
assertIsNone
(
repo
.
delete
())
with
self
.
assertRaises
(
RuntimeError
):
repo
.
refresh
()
def
test_create_mr
(
self
):
fork
=
self
.
fork_repo
.
create_fork
()
...
...
tests/GitLab/cassettes/GitLabRepositoryTest.test_repo_create_and_delete.yaml
0 → 100644
View file @
0be225aa
interactions
:
-
request
:
body
:
'
{"name":
"test-repo",
"visibility":
"public",
"default_branch":
"master",
"has_issues":
true,
"has_merge_requests":
true,
"has_jobs":
true,
"has_wiki":
true,
"has_snippets":
true,
"has_container_registry":
true,
"has_shared_runners":
true,
"has_lfs":
false,
"resolve_outdated_diff_discussions":
false,
"public_jobs":
false,
"only_allow_merge_if_pipeline_succeeds":
false,
"only_allow_merge_if_all_discussions_are_resolved":
false,
"allow_request_access":
true,
"allow_printing_merge_request_link":
true}'
headers
:
Accept
:
[
'
*/*'
]
Accept-Encoding
:
[
'
gzip,
deflate'
]
Connection
:
[
keep-alive
]
Content-Length
:
[
'
503'
]
Content-Type
:
[
application/json
]
If-None-Match
:
[
W/"ee98c600238675d485637e80551916fe"
]
User-Agent
:
[
IGitt
]
method
:
POST
uri
:
https://gitlab.com/api/v4/projects
response
:
body
:
{
string
:
"
{
\"
id
\"
:5939856,
\"
description
\"
:null,
\"
name
\"
:
\"
test-repo
\"
,
\"
name_with_namespace
\"
:
\"
GitMate
Labs
\U0001F47D
/
test-repo
\"
,
\"
path
\"
:
\"
test-repo
\"
,
\"
path_with_namespace
\"
:
\"
gitmate-test-user/test-repo
\"
,
\"
created_at
\"
:
\"
2018-04-01T22:44:48.418Z
\"
,
\"
default_branch
\"
:null,
\"
tag_list
\"
:[],
\"
ssh_url_to_repo
\"
:
\"
git@gitlab.com:gitmate-test-user/test-repo.git
\"
,
\"
http_url_to_repo
\"
:
\"
https://gitlab.com/gitmate-test-user/test-repo.git
\"
,
\"
web_url
\"
:
\"
https://gitlab.com/gitmate-test-user/test-repo
\"
,
\"
avatar_url
\"
:null,
\"
star_count
\"
:0,
\"
forks_count
\"
:0,
\"
last_activity_at
\"
:
\"
2018-04-01T22:44:48.418Z
\"
,
\"
_links
\"
:{
\"
self
\"
:
\"
https://gitlab.com/api/v4/projects/5939856
\"
,
\"
issues
\"
:
\"
https://gitlab.com/api/v4/projects/5939856/issues
\"
,
\"
merge_requests
\"
:
\"
https://gitlab.com/api/v4/projects/5939856/merge_requests
\"
,
\"
repo_branches
\"
:
\"
https://gitlab.com/api/v4/projects/5939856/repository/branches
\"
,
\"
labels
\"
:
\"
https://gitlab.com/api/v4/projects/5939856/labels
\"
,
\"
events
\"
:
\"
https://gitlab.com/api/v4/projects/5939856/events
\"
,
\"
members
\"
:
\"
https://gitlab.com/api/v4/projects/5939856/members
\"
},
\"
archived
\"
:false,
\"
visibility
\"
:
\"
public
\"
,
\"
owner
\"
:{
\"
id
\"
:1369631,
\"
name
\"
:
\"
GitMate
Labs
\U0001F47D\"
,
\"
username
\"
:
\"
gitmate-test-user
\"
,
\"
state
\"
:
\"
active
\"
,
\"
avatar_url
\"
:
\"
https://assets.gitlab-static.net/uploads/-/system/user/avatar/1369631/avatar.png
\"
,
\"
web_url
\"
:
\"
https://gitlab.com/gitmate-test-user
\"
},
\"
resolve_outdated_diff_discussions
\"
:false,
\"
container_registry_enabled
\"
:true,
\"
issues_enabled
\"
:true,
\"
merge_requests_enabled
\"
:true,
\"
wiki_enabled
\"
:true,
\"
jobs_enabled
\"
:true,
\"
snippets_enabled
\"
:true,
\"
shared_runners_enabled
\"
:true,
\"
lfs_enabled
\"
:true,
\"
creator_id
\"
:1369631,
\"
namespace
\"
:{
\"
id
\"
:1652018,
\"
name
\"
:
\"
gitmate-test-user
\"
,
\"
path
\"
:
\"
gitmate-test-user
\"
,
\"
kind
\"
:
\"
user
\"
,
\"
full_path
\"
:
\"
gitmate-test-user
\"
,
\"
parent_id
\"
:null},
\"
import_status
\"
:
\"
none
\"
,
\"
import_error
\"
:null,
\"
open_issues_count
\"
:0,
\"
runners_token
\"
:
\"
hPhHqyksf4VXf4syEqG6
\"
,
\"
public_jobs
\"
:true,
\"
ci_config_path
\"
:null,
\"
shared_with_groups
\"
:[],
\"
only_allow_merge_if_pipeline_succeeds
\"
:false,
\"
request_access_enabled
\"
:false,
\"
only_allow_merge_if_all_discussions_are_resolved
\"
:false,
\"
printing_merge_request_link_enabled
\"
:true,
\"
approvals_before_merge
\"
:0}"
}
headers
:
Cache-Control
:
[
'
max-age=0,
private,
must-revalidate'
]
Content-Length
:
[
'
2074'
]
Content-Type
:
[
application/json
]
Date
:
[
'
Sun,
01
Apr
2018
22:44:49
GMT'
]
Etag
:
[
W/"dd5224a442e05bcd269bae9f8ed79994"
]
RateLimit-Limit
:
[
'
600'
]
RateLimit-Observed
:
[
'
2'
]
RateLimit-Remaining
:
[
'
598'
]
RateLimit-Reset
:
[
'
1522622749'
]
RateLimit-ResetTime
:
[
'
Mon,
01
Apr
2018
22:45:49
GMT'
]
Server
:
[
nginx
]
Strict-Transport-Security
:
[
max-age=31536000
]
Vary
:
[
Origin
]
X-Content-Type-Options
:
[
nosniff
]
X-Frame-Options
:
[
SAMEORIGIN
]
X-Request-Id
:
[
f1cf625a-912b-4ec5-a2e1-421772f03acd
]
X-Runtime
:
[
'
1.581962'
]
status
:
{
code
:
201
,
message
:
Created
}
-
request
:
body
:
'
{}'
headers
:
Accept
:
[
'
*/*'
]
Accept-Encoding
:
[
'
gzip,
deflate'
]
Connection
:
[
keep-alive
]
Content-Length
:
[
'
2'
]
Content-Type
:
[
application/json
]
User-Agent
:
[
IGitt
]