diff options
| author | Nejc Habjan <hab.nejc@gmail.com> | 2021-10-09 15:35:32 +0200 |
|---|---|---|
| committer | Nejc Habjan <hab.nejc@gmail.com> | 2021-10-11 22:49:46 +0200 |
| commit | 545f8ed24124837bf4e55aa34e185270a4b7aeff (patch) | |
| tree | adad76b598b917d9ca77ed600dcd62c63af67950 /docs/gl_objects | |
| parent | 5a1678f43184bd459132102cc13cf8426fe0449d (diff) | |
| download | gitlab-chore/master-to-main.tar.gz | |
chore: rename `master` branch to `main`chore/master-to-main
BREAKING CHANGE: As of python-gitlab 3.0.0, the default branch for development
has changed from `master` to `main`.
Diffstat (limited to 'docs/gl_objects')
| -rw-r--r-- | docs/gl_objects/branches.rst | 4 | ||||
| -rw-r--r-- | docs/gl_objects/commits.rst | 2 | ||||
| -rw-r--r-- | docs/gl_objects/deployments.rst | 2 | ||||
| -rw-r--r-- | docs/gl_objects/mrs.rst | 2 | ||||
| -rw-r--r-- | docs/gl_objects/pipelines_and_jobs.rst | 12 | ||||
| -rw-r--r-- | docs/gl_objects/projects.rst | 26 | ||||
| -rw-r--r-- | docs/gl_objects/protected_branches.rst | 2 |
7 files changed, 25 insertions, 25 deletions
diff --git a/docs/gl_objects/branches.rst b/docs/gl_objects/branches.rst index aeba8ea..a9c80c0 100644 --- a/docs/gl_objects/branches.rst +++ b/docs/gl_objects/branches.rst @@ -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:: diff --git a/docs/gl_objects/commits.rst b/docs/gl_objects/commits.rst index a1d878c..efe6546 100644 --- a/docs/gl_objects/commits.rst +++ b/docs/gl_objects/commits.rst @@ -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': [ { diff --git a/docs/gl_objects/deployments.rst b/docs/gl_objects/deployments.rst index 945ad41..ae10103 100644 --- a/docs/gl_objects/deployments.rst +++ b/docs/gl_objects/deployments.rst @@ -29,7 +29,7 @@ Create a new deployment:: deployment = project.deployments.create({ "environment": "Test", "sha": "1agf4gs", - "ref": "master", + "ref": "main", "tag": False, "status": "created", }) diff --git a/docs/gl_objects/mrs.rst b/docs/gl_objects/mrs.rst index f17ad26..9ec69e5 100644 --- a/docs/gl_objects/mrs.rst +++ b/docs/gl_objects/mrs.rst @@ -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']}) diff --git a/docs/gl_objects/pipelines_and_jobs.rst b/docs/gl_objects/pipelines_and_jobs.rst index 675ff4e..b4761b0 100644 --- a/docs/gl_objects/pipelines_and_jobs.rst +++ b/docs/gl_objects/pipelines_and_jobs.rst @@ -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:: @@ -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) @@ -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 @@ -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 * * *'}) @@ -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:: @@ -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:: diff --git a/docs/gl_objects/projects.rst b/docs/gl_objects/projects.rst index fdf5ac5..0b251ea 100644 --- a/docs/gl_objects/projects.rst +++ b/docs/gl_objects/projects.rst @@ -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 ) @@ -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']: @@ -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) @@ -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', @@ -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 ============ @@ -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:: @@ -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:: diff --git a/docs/gl_objects/protected_branches.rst b/docs/gl_objects/protected_branches.rst index 3498aa5..88e046c 100644 --- a/docs/gl_objects/protected_branches.rst +++ b/docs/gl_objects/protected_branches.rst @@ -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:: |
