Skip to content

chore: rename master branch to main #1629

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 1 commit into from
Oct 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ name: Docs
on:
push:
branches:
- master
- main
pull_request:
branches:
- main
- master

env:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ name: Lint
on:
push:
branches:
- master
- main
pull_request:
branches:
- main
- master

env:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ name: Test
on:
push:
branches:
- master
- main
pull_request:
branches:
- main
- master

env:
Expand Down
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
.. image:: https://readthedocs.org/projects/python-gitlab/badge/?version=latest
:target: https://python-gitlab.readthedocs.org/en/latest/?badge=latest

.. image:: https://codecov.io/github/python-gitlab/python-gitlab/coverage.svg?branch=master
:target: https://codecov.io/github/python-gitlab/python-gitlab?branch=master
.. image:: https://codecov.io/github/python-gitlab/python-gitlab/coverage.svg?branch=main
:target: https://codecov.io/github/python-gitlab/python-gitlab?branch=main

.. image:: https://img.shields.io/pypi/pyversions/python-gitlab.svg
:target: https://pypi.python.org/pypi/python-gitlab
Expand Down Expand Up @@ -96,4 +96,4 @@ You can build the documentation using ``sphinx``::
Contributing
============

For guidelines for contributing to ``python-gitlab``, refer to `CONTRIBUTING.rst <https://github.com/python-gitlab/python-gitlab/blob/master/CONTRIBUTING.rst>`_.
For guidelines for contributing to ``python-gitlab``, refer to `CONTRIBUTING.rst <https://github.com/python-gitlab/python-gitlab/blob/main/CONTRIBUTING.rst>`_.
4 changes: 2 additions & 2 deletions docs/gl_objects/branches.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ Get the list of branches for a repository::

Get a single repository branch::

branch = project.branches.get('master')
branch = project.branches.get('main')

Create a repository branch::

branch = project.branches.create({'branch': 'feature1',
'ref': 'master'})
'ref': 'main'})

Delete a repository branch::

Expand Down
2 changes: 1 addition & 1 deletion docs/gl_objects/commits.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Create a commit::
# See https://docs.gitlab.com/ce/api/commits.html#create-a-commit-with-multiple-files-and-actions
# for actions detail
data = {
'branch': 'master',
'branch': 'main',
'commit_message': 'blah blah blah',
'actions': [
{
Expand Down
2 changes: 1 addition & 1 deletion docs/gl_objects/deployments.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Create a new deployment::
deployment = project.deployments.create({
"environment": "Test",
"sha": "1agf4gs",
"ref": "master",
"ref": "main",
"tag": False,
"status": "created",
})
Expand Down
2 changes: 1 addition & 1 deletion docs/gl_objects/mrs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Get a single MR::
Create a MR::

mr = project.mergerequests.create({'source_branch': 'cool_feature',
'target_branch': 'master',
'target_branch': 'main',
'title': 'merge cool feature',
'labels': ['label1', 'label2']})

Expand Down
12 changes: 6 additions & 6 deletions docs/gl_objects/pipelines_and_jobs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Get variables of a pipeline::

Create a pipeline for a particular reference with custom variables::

pipeline = project.pipelines.create({'ref': 'master', 'variables': [{'key': 'MY_VARIABLE', 'value': 'hello'}]})
pipeline = project.pipelines.create({'ref': 'main', 'variables': [{'key': 'MY_VARIABLE', 'value': 'hello'}]})

Retry the failed builds for a pipeline::

Expand Down Expand Up @@ -97,7 +97,7 @@ Full example with wait for finish::
return project.triggers.create({'description': trigger_decription})

trigger = get_or_create_trigger(project)
pipeline = project.trigger_pipeline('master', trigger.token, variables={"DEPLOY_ZONE": "us-west1"})
pipeline = project.trigger_pipeline('main', trigger.token, variables={"DEPLOY_ZONE": "us-west1"})
while pipeline.finished_at is None:
pipeline.refresh()
time.sleep(1)
Expand All @@ -108,7 +108,7 @@ objects to get the associated project::

gl = gitlab.Gitlab(URL) # no authentication
project = gl.projects.get(project_id, lazy=True) # no API call
project.trigger_pipeline('master', trigger_token)
project.trigger_pipeline('main', trigger_token)

Reference: https://docs.gitlab.com/ee/ci/triggers/#trigger-token

Expand Down Expand Up @@ -146,7 +146,7 @@ Get a single schedule::
Create a new schedule::

sched = project.pipelineschedules.create({
'ref': 'master',
'ref': 'main',
'description': 'Daily test',
'cron': '0 1 * * *'})

Expand Down Expand Up @@ -213,7 +213,7 @@ Examples
Jobs are usually automatically triggered, but you can explicitly trigger a new
job::

project.trigger_build('master', trigger_token,
project.trigger_build('main', trigger_token,
{'extra_var1': 'foo', 'extra_var2': 'bar'})

List jobs for the project::
Expand Down Expand Up @@ -247,7 +247,7 @@ Get the artifacts of a job::
Get the artifacts of a job by its name from the latest successful pipeline of
a branch or tag:

project.artifacts(ref_name='master', job='build')
project.artifacts(ref_name='main', job='build')

.. warning::

Expand Down
26 changes: 13 additions & 13 deletions docs/gl_objects/projects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ Update a project submodule::

items = project.update_submodule(
submodule="foo/bar",
branch="master",
branch="main",
commit_sha="4c3674f66071e30b3311dac9b9ccc90502a72664",
commit_message="Message", # optional
)
Expand Down Expand Up @@ -199,7 +199,7 @@ Get a snapshot of the repository::

Compare two branches, tags or commits::

result = project.repository_compare('master', 'branch1')
result = project.repository_compare('main', 'branch1')

# get the commits
for commit in result['commits']:
Expand Down Expand Up @@ -340,7 +340,7 @@ Examples

Get a file::

f = project.files.get(file_path='README.rst', ref='master')
f = project.files.get(file_path='README.rst', ref='main')

# get the base64 encoded content
print(f.content)
Expand All @@ -350,15 +350,15 @@ Get a file::

Get a raw file::

raw_content = project.files.raw(file_path='README.rst', ref='master')
raw_content = project.files.raw(file_path='README.rst', ref='main')
print(raw_content)
with open('/tmp/raw-download.txt', 'wb') as f:
project.files.raw(file_path='README.rst', ref='master', streamed=True, action=f.write)
project.files.raw(file_path='README.rst', ref='main', streamed=True, action=f.write)

Create a new file::

f = project.files.create({'file_path': 'testfile.txt',
'branch': 'master',
'branch': 'main',
'content': file_content,
'author_email': 'test@example.com',
'author_name': 'yourname',
Expand All @@ -369,23 +369,23 @@ Update a file. The entire content must be uploaded, as plain text or as base64
encoded text::

f.content = 'new content'
f.save(branch='master', commit_message='Update testfile')
f.save(branch='main', commit_message='Update testfile')

# or for binary data
# Note: decode() is required with python 3 for data serialization. You can omit
# it with python 2
f.content = base64.b64encode(open('image.png').read()).decode()
f.save(branch='master', commit_message='Update testfile', encoding='base64')
f.save(branch='main', commit_message='Update testfile', encoding='base64')

Delete a file::

f.delete(commit_message='Delete testfile', branch='master')
f.delete(commit_message='Delete testfile', branch='main')
# or
project.files.delete(file_path='testfile.txt', commit_message='Delete testfile', branch='master')
project.files.delete(file_path='testfile.txt', commit_message='Delete testfile', branch='main')

Get file blame::

b = project.files.blame(file_path='README.rst', ref='master')
b = project.files.blame(file_path='README.rst', ref='main')

Project tags
============
Expand Down Expand Up @@ -414,7 +414,7 @@ Get a tag::

Create a tag::

tag = project.tags.create({'tag_name': '1.0', 'ref': 'master'})
tag = project.tags.create({'tag_name': '1.0', 'ref': 'main'})

Delete a tag::

Expand Down Expand Up @@ -702,7 +702,7 @@ Get project push rules (returns None is there are no push rules)::

Edit project push rules::

pr.branch_name_regex = '^(master|develop|support-\d+|release-\d+\..+|hotfix-.+|feature-.+)$'
pr.branch_name_regex = '^(main|develop|support-\d+|release-\d+\..+|hotfix-.+|feature-.+)$'
pr.save()

Delete project push rules::
Expand Down
2 changes: 1 addition & 1 deletion docs/gl_objects/protected_branches.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Get the list of protected branches for a project::

Get a single protected branch::

p_branch = project.protectedbranches.get('master')
p_branch = project.protectedbranches.get('main')

Create a protected branch::

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module = [
ignore_errors = false

[tool.semantic_release]
branch = "main"
version_variable = "gitlab/__version__.py:__version__"
commit_subject = "chore: release v{version}"
commit_message = ""
6 changes: 3 additions & 3 deletions tests/functional/api/test_merge_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ def test_merge_requests(project):
project.files.create(
{
"file_path": "README.rst",
"branch": "master",
"branch": "main",
"content": "Initial content",
"commit_message": "Initial commit",
}
)

source_branch = "branch1"
project.branches.create({"branch": source_branch, "ref": "master"})
project.branches.create({"branch": source_branch, "ref": "main"})

project.files.create(
{
Expand All @@ -28,7 +28,7 @@ def test_merge_requests(project):
}
)
project.mergerequests.create(
{"source_branch": "branch1", "target_branch": "master", "title": "MR readme2"}
{"source_branch": "branch1", "target_branch": "main", "title": "MR readme2"}
)


Expand Down
2 changes: 1 addition & 1 deletion tests/functional/api/test_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def test_project_stars(project):


def test_project_tags(project, project_file):
tag = project.tags.create({"tag_name": "v1.0", "ref": "master"})
tag = project.tags.create({"tag_name": "v1.0", "ref": "main"})
assert len(project.tags.list()) == 1

tag.delete()
Expand Down
22 changes: 11 additions & 11 deletions tests/functional/api/test_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,32 @@ def test_repository_files(project):
project.files.create(
{
"file_path": "README",
"branch": "master",
"branch": "main",
"content": "Initial content",
"commit_message": "Initial commit",
}
)
readme = project.files.get(file_path="README", ref="master")
readme = project.files.get(file_path="README", ref="main")
readme.content = base64.b64encode(b"Improved README").decode()

time.sleep(2)
readme.save(branch="master", commit_message="new commit")
readme.delete(commit_message="Removing README", branch="master")
readme.save(branch="main", commit_message="new commit")
readme.delete(commit_message="Removing README", branch="main")

project.files.create(
{
"file_path": "README.rst",
"branch": "master",
"branch": "main",
"content": "Initial content",
"commit_message": "New commit",
}
)
readme = project.files.get(file_path="README.rst", ref="master")
readme = project.files.get(file_path="README.rst", ref="main")
# The first decode() is the ProjectFile method, the second one is the bytes
# object method
assert readme.decode().decode() == "Initial content"

blame = project.files.blame(file_path="README.rst", ref="master")
blame = project.files.blame(file_path="README.rst", ref="main")
assert blame


Expand All @@ -51,7 +51,7 @@ def test_repository_tree(project):
archive = project.repository_archive()
assert isinstance(archive, bytes)

archive2 = project.repository_archive("master")
archive2 = project.repository_archive("main")
assert archive == archive2

snapshot = project.snapshot()
Expand All @@ -60,7 +60,7 @@ def test_repository_tree(project):

def test_create_commit(project):
data = {
"branch": "master",
"branch": "main",
"commit_message": "blah blah blah",
"actions": [{"action": "create", "file_path": "blah", "content": "blah"}],
}
Expand Down Expand Up @@ -114,7 +114,7 @@ def test_commit_discussion(project):

def test_revert_commit(project):
commit = project.commits.list()[0]
revert_commit = commit.revert(branch="master")
revert_commit = commit.revert(branch="main")

expected_message = 'Revert "{}"\n\nThis reverts commit {}'.format(
commit.message, commit.id
Expand All @@ -123,4 +123,4 @@ def test_revert_commit(project):

with pytest.raises(gitlab.GitlabRevertError):
# Two revert attempts should raise GitlabRevertError
commit.revert(branch="master")
commit.revert(branch="main")
2 changes: 1 addition & 1 deletion tests/functional/cli/test_cli_artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
)
data = {
"file_path": ".gitlab-ci.yml",
"branch": "master",
"branch": "main",
"content": content,
"commit_message": "Initial commit",
}
Expand Down
Loading