Skip to content

Commit

Permalink
Rename master to main (#1257)
Browse files Browse the repository at this point in the history
* Rename master to main

* Remove unneeded await

* More integration tests fixes

* Lint the code
fcollonval authored Aug 3, 2023
1 parent a49a53a commit db7bd77
Showing 15 changed files with 87 additions and 85 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ name: Build

on:
push:
branches: ['master']
branches: ['main']
pull_request:
branches: ['*']

2 changes: 1 addition & 1 deletion .github/workflows/check-release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Check Release
on:
push:
branches: ["master"]
branches: ["main"]
pull_request:
branches: ["*"]

10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# jupyterlab-git

[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/jupyterlab/jupyterlab-git/master?urlpath=lab/tree/examples/demo.ipynb) [![Github Actions Status](https://github.com/jupyterlab/jupyterlab-git/actions/workflows/build.yml/badge.svg)](https://github.com/jupyterlab/jupyterlab-git/actions/workflows/build.yml) [![Version](https://img.shields.io/npm/v/@jupyterlab/git.svg)](https://www.npmjs.com/package/@jupyterlab/git) [![Version](https://img.shields.io/pypi/v/jupyterlab-git.svg)](https://pypi.org/project/jupyterlab-git/) [![Downloads](https://img.shields.io/npm/dm/@jupyterlab/git.svg)](https://www.npmjs.com/package/@jupyterlab/git) [![Version](https://img.shields.io/conda/vn/conda-forge/jupyterlab-git.svg)](https://anaconda.org/conda-forge/jupyterlab-git) [![Downloads](https://img.shields.io/conda/dn/conda-forge/jupyterlab-git.svg)](https://anaconda.org/conda-forge/jupyterlab-git)<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/jupyterlab/jupyterlab-git/main?urlpath=lab/tree/examples/demo.ipynb) [![Github Actions Status](https://github.com/jupyterlab/jupyterlab-git/actions/workflows/build.yml/badge.svg)](https://github.com/jupyterlab/jupyterlab-git/actions/workflows/build.yml) [![Version](https://img.shields.io/npm/v/@jupyterlab/git.svg)](https://www.npmjs.com/package/@jupyterlab/git) [![Version](https://img.shields.io/pypi/v/jupyterlab-git.svg)](https://pypi.org/project/jupyterlab-git/) [![Downloads](https://img.shields.io/npm/dm/@jupyterlab/git.svg)](https://www.npmjs.com/package/@jupyterlab/git) [![Version](https://img.shields.io/conda/vn/conda-forge/jupyterlab-git.svg)](https://anaconda.org/conda-forge/jupyterlab-git) [![Downloads](https://img.shields.io/conda/dn/conda-forge/jupyterlab-git.svg)](https://anaconda.org/conda-forge/jupyterlab-git)<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-29-orange.svg?style=flat-square)](#contributors-)

<!-- ALL-CONTRIBUTORS-BADGE:END -->

A JupyterLab extension for version control using Git

![ui_glow_up](https://raw.githubusercontent.com/jupyterlab/jupyterlab-git/master/docs/figs/preview.gif)
![ui_glow_up](https://raw.githubusercontent.com/jupyterlab/jupyterlab-git/main/docs/figs/preview.gif)

To see the extension in action, open the example notebook included in the Binder [demo](https://mybinder.org/v2/gh/jupyterlab/jupyterlab-git/master?urlpath=lab/tree/examples/demo.ipynb).
To see the extension in action, open the example notebook included in the Binder [demo](https://mybinder.org/v2/gh/jupyterlab/jupyterlab-git/main?urlpath=lab/tree/examples/demo.ipynb).

## Requirements

@@ -193,9 +193,9 @@ Possible fixes:

## Contributing

If you would like to contribute to the project, please read our [contributor documentation](https://github.com/jupyterlab/jupyterlab/blob/master/CONTRIBUTING.md).
If you would like to contribute to the project, please read our [contributor documentation](https://github.com/jupyterlab/jupyterlab/blob/main/CONTRIBUTING.md).

JupyterLab follows the official [Jupyter Code of Conduct](https://github.com/jupyter/governance/blob/master/conduct/code_of_conduct.md).
JupyterLab follows the official [Jupyter Code of Conduct](https://github.com/jupyter/governance/blob/main/conduct/code_of_conduct.md).

### Development install

26 changes: 13 additions & 13 deletions jupyterlab_git/tests/test_branch.py
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
"branch,expected",
[
("refs/heads/feature-foo", False),
("refs/heads/master", False),
("refs/heads/main", False),
("refs/remotes/origin/feature-foo", True),
("refs/remotes/origin/HEAD", True),
("refs/stash", False),
@@ -403,7 +403,7 @@ async def test_get_current_branch_detached_success():
# Given
process_output = [
"* (HEAD detached at origin/feature-foo)",
" master",
" main",
" remotes/origin/feature-foo",
" remotes/origin/HEAD",
]
@@ -466,8 +466,8 @@ async def test_get_current_branch_detached_failure():
@pytest.mark.parametrize(
"branch,upstream,remotename",
[
("feature-foo", "master", "origin/withslash"),
("master", "master", "origin"),
("feature-foo", "main", "origin/withslash"),
("main", "main", "origin"),
("feature/bar", "feature-foo", ""),
# Test upstream branch name starts with a letter contained in remote name
("rbranch", "rbranch", "origin"),
@@ -698,12 +698,12 @@ async def test_branch_success():
# Given
process_output_heads = [
"feature-foo\tabcdefghijklmnopqrstuvwxyz01234567890123\torigin/feature-foo\t*",
"master\tabcdefghijklmnopqrstuvwxyz01234567890123\torigin/master\t ",
"main\tabcdefghijklmnopqrstuvwxyz01234567890123\torigin/main\t ",
"feature-bar\t01234567899999abcdefghijklmnopqrstuvwxyz\t\t ",
]
process_output_remotes = [
"origin/feature-foo\tabcdefghijklmnopqrstuvwxyz01234567890123",
"origin/master\tabcdefghijklmnopqrstuvwxyz01234567890123",
"origin/main\tabcdefghijklmnopqrstuvwxyz01234567890123",
]

mock_execute.side_effect = [
@@ -727,8 +727,8 @@ async def test_branch_success():
{
"is_current_branch": False,
"is_remote_branch": False,
"name": "master",
"upstream": "origin/master",
"name": "main",
"upstream": "origin/main",
"top_commit": "abcdefghijklmnopqrstuvwxyz01234567890123",
"tag": None,
},
@@ -751,7 +751,7 @@ async def test_branch_success():
{
"is_current_branch": False,
"is_remote_branch": True,
"name": "origin/master",
"name": "origin/main",
"upstream": None,
"top_commit": "abcdefghijklmnopqrstuvwxyz01234567890123",
"tag": None,
@@ -855,14 +855,14 @@ async def test_branch_success_detached_head():
with patch("jupyterlab_git.git.execute") as mock_execute:
# Given
process_output_heads = [
"master\tabcdefghijklmnopqrstuvwxyz01234567890123\torigin/master\t "
"main\tabcdefghijklmnopqrstuvwxyz01234567890123\torigin/main\t "
]
process_output_remotes = [
"origin/feature-foo\tabcdefghijklmnopqrstuvwxyz01234567890123"
]
detached_head_output = [
"* (HEAD detached at origin/feature-foo)",
" master",
" main",
" remotes/origin/feature-foo",
]

@@ -883,8 +883,8 @@ async def test_branch_success_detached_head():
{
"is_current_branch": False,
"is_remote_branch": False,
"name": "master",
"upstream": "origin/master",
"name": "main",
"upstream": "origin/main",
"top_commit": "abcdefghijklmnopqrstuvwxyz01234567890123",
"tag": None,
},
6 changes: 3 additions & 3 deletions jupyterlab_git/tests/test_config.py
Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@ async def test_git_get_config_multiline(mock_execute, jp_fetch, jp_root_dir):
'" $(git rev-parse --abbrev-ref HEAD); printf "\n'
"Most-active files, with churn count\n"
'"; git churn | head -7; }; f\n'
'alias.topic-base-branch-name=!f(){ printf "master\n'
'alias.topic-base-branch-name=!f(){ printf "main\n'
'"; };f\n'
'alias.topic-start=!f(){ topic_branch="$1"; git topic-create "$topic_branch"; git topic-push; };f'
)
@@ -101,7 +101,7 @@ async def test_git_get_config_accepted_multiline(mock_execute, jp_fetch, jp_root
'" $(git rev-parse --abbrev-ref HEAD); printf "\n'
"Most-active files, with churn count\n"
'"; git churn | head -7; }; f\n'
'alias.topic-base-branch-name=!f(){ printf "master\n'
'alias.topic-base-branch-name=!f(){ printf "main\n'
'"; };f\n'
'alias.topic-start=!f(){ topic_branch="$1"; git topic-create "$topic_branch"; git topic-push; };f'
)
@@ -134,7 +134,7 @@ async def test_git_get_config_accepted_multiline(mock_execute, jp_fetch, jp_root
'" $(git rev-parse --abbrev-ref HEAD); printf "\n'
"Most-active files, with churn count\n"
'"; git churn | head -7; }; f',
"alias.topic-base-branch-name": '!f(){ printf "master\n"; };f',
"alias.topic-base-branch-name": '!f(){ printf "main\n"; };f',
},
}

6 changes: 3 additions & 3 deletions jupyterlab_git/tests/test_handlers.py
Original file line number Diff line number Diff line change
@@ -258,8 +258,8 @@ async def test_branch_handler_localbranch(mock_git, jp_fetch, jp_root_dir):
{
"is_current_branch": False,
"is_remote_branch": False,
"name": "master",
"upstream": "origin/master",
"name": "main",
"upstream": "origin/main",
"top_commit": "abcdefghijklmnopqrstuvwxyz01234567890123",
"tag": None,
},
@@ -282,7 +282,7 @@ async def test_branch_handler_localbranch(mock_git, jp_fetch, jp_root_dir):
{
"is_current_branch": False,
"is_remote_branch": True,
"name": "origin/master",
"name": "origin/main",
"upstream": None,
"top_commit": "abcdefghijklmnopqrstuvwxyz01234567890123",
"tag": None,
34 changes: 17 additions & 17 deletions jupyterlab_git/tests/test_status.py
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
[
(
(
"## master",
"## main",
"A notebook with spaces.ipynb",
"M notebook with λ.ipynb",
"M binary file.gif",
@@ -29,7 +29,7 @@
),
{
"code": 0,
"branch": "master",
"branch": "main",
"remote": None,
"ahead": 0,
"behind": 0,
@@ -74,11 +74,11 @@
),
# Empty answer
(
("## master",),
("## main",),
(""),
{
"code": 0,
"branch": "master",
"branch": "main",
"remote": None,
"ahead": 0,
"behind": 0,
@@ -87,59 +87,59 @@
),
# With upstream only
(
("## master...origin/master",),
("## main...origin/main",),
(""),
{
"code": 0,
"branch": "master",
"remote": "origin/master",
"branch": "main",
"remote": "origin/main",
"ahead": 0,
"behind": 0,
"files": [],
},
),
# Ahead only
(
("## master...origin/master [ahead 15]",),
("## main...origin/main [ahead 15]",),
(""),
{
"code": 0,
"branch": "master",
"remote": "origin/master",
"branch": "main",
"remote": "origin/main",
"ahead": 15,
"behind": 0,
"files": [],
},
),
# Behind only
(
("## master...origin/master [behind 5]",),
("## main...origin/main [behind 5]",),
(""),
{
"code": 0,
"branch": "master",
"remote": "origin/master",
"branch": "main",
"remote": "origin/main",
"ahead": 0,
"behind": 5,
"files": [],
},
),
# Ahead and behind
(
("## master...origin/master [ahead 3, behind 5]",),
("## main...origin/main [ahead 3, behind 5]",),
(""),
{
"code": 0,
"branch": "master",
"remote": "origin/master",
"branch": "main",
"remote": "origin/main",
"ahead": 3,
"behind": 5,
"files": [],
},
),
# Initial commit
(
("## No commits yet on master",),
("## No commits yet on main",),
(""),
{
"code": 0,
12 changes: 6 additions & 6 deletions specification/Git_REST_API.yml
Original file line number Diff line number Diff line change
@@ -811,7 +811,7 @@ on git command failure
```

# ### git pull - Fetch from and integrate with another repository or a local branch
# Request with a specified remote-repo "origin", a specified branch "master", and a "curr_fb_path" to fetch.
# Request with a specified remote-repo "origin", a specified branch "main", and a "curr_fb_path" to fetch.

# URL:
# ```bash
@@ -821,7 +821,7 @@ on git command failure
# ```bash
# {
# "origin": "remote-repository-to-Pull-from",
# "master": "branch-to-Pull-into",
# "main": "branch-to-Pull-into",
# "curr_fb_path": "current/path/in/filebrowser/widget"
# }
# ```
@@ -843,13 +843,13 @@ on git command failure
# ```bash
# {
# "code": 11,
# "command": "git pull origin master"
# "command": "git pull origin main"
# "message": "Git pull command error and help tips"
# }
# ```

# ### git push - Update remote refs along with associated objects
# Request with a specified remote-repo "origin", a specified branch "master", and a "curr_fb_path" to push.
# Request with a specified remote-repo "origin", a specified branch "main", and a "curr_fb_path" to push.

# URL:
# ```bash
@@ -859,7 +859,7 @@ on git command failure
# ```bash
# {
# "origin": "remote-repository-to-Push-into",
# "master": "branch-to-Push-from",
# "main": "branch-to-Push-from",
# "curr_fb_path": "current/path/in/filebrowser/widget"
# }
# ```
@@ -881,7 +881,7 @@ on git command failure
# ```bash
# {
# "code": 11,
# "command": "git push origin master"
# "command": "git push origin main"
# "message": "Git push command error and help tips"
# }
# ```
8 changes: 4 additions & 4 deletions src/__tests__/model.spec.tsx
Original file line number Diff line number Diff line change
@@ -215,7 +215,7 @@ describe('IGitExtension', () => {
expect(model.status.files).toHaveLength(0);

model.pathRepository = DEFAULT_REPOSITORY_PATH;
const branch = 'master';
const branch = 'main';
await model.ready;
status = {
branch,
@@ -236,7 +236,7 @@ describe('IGitExtension', () => {
});

it('should emit a signal if when set', async () => {
const branch = 'master';
const branch = 'main';
const status: Partial<Git.IStatusResult> = {
branch,
remote: null,
@@ -337,7 +337,7 @@ describe('IGitExtension', () => {
{
is_current_branch: true,
is_remote_branch: false,
name: 'master',
name: 'main',
upstream: null,
top_commit: '52263564aac988a0888060becc3c76d1023e680f',
tag: null
@@ -354,7 +354,7 @@ describe('IGitExtension', () => {
current_branch: {
is_current_branch: true,
is_remote_branch: false,
name: 'master',
name: 'main',
upstream: null,
top_commit: '52263564aac988a0888060becc3c76d1023e680f',
tag: null
10 changes: 5 additions & 5 deletions src/__tests__/test-components/BranchMenu.spec.tsx
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ const BRANCHES = [
{
is_current_branch: true,
is_remote_branch: false,
name: 'master',
name: 'main',
upstream: '',
top_commit: '',
tag: ''
@@ -194,15 +194,15 @@ describe('BranchMenu', () => {
{
is_current_branch: false,
is_remote_branch: false,
name: 'master',
name: 'main',
upstream: '',
top_commit: '',
tag: ''
},
{
is_current_branch: false,
is_remote_branch: true,
name: 'master',
name: 'main',
upstream: '',
top_commit: '',
tag: ''
@@ -251,7 +251,7 @@ describe('BranchMenu', () => {
});

const spy = jest.spyOn(GitExtension.prototype, 'deleteBranch');
const branchName = 'master';
const branchName = 'main';

const menu = mount(
<BranchMenu
@@ -285,7 +285,7 @@ describe('BranchMenu', () => {
});

it('should call merge branch when clicked on the merge button', async () => {
const branchName = 'master';
const branchName = 'main';
const fakeExecutioner = jest.fn();

const menu = mount(
14 changes: 7 additions & 7 deletions src/__tests__/test-components/Toolbar.spec.tsx
Original file line number Diff line number Diff line change
@@ -29,20 +29,20 @@ describe('Toolbar', () => {

function createProps(props?: Partial<IToolbarProps>): IToolbarProps {
return {
currentBranch: 'master',
currentBranch: 'main',
branches: [
{
is_current_branch: true,
is_remote_branch: false,
name: 'master',
upstream: 'origin/master',
name: 'main',
upstream: 'origin/main',
top_commit: '',
tag: ''
},
{
is_current_branch: false,
is_remote_branch: true,
name: 'origin/master',
name: 'origin/main',
upstream: '',
top_commit: '',
tag: ''
@@ -193,7 +193,7 @@ describe('Toolbar', () => {
});

it('should set the `title` attribute on the button to toggle a branch menu', () => {
const currentBranch = 'master';
const currentBranch = 'main';
const toolbar = shallow<Toolbar>(
<Toolbar {...createProps({ currentBranch })} />
);
@@ -251,7 +251,7 @@ describe('Toolbar', () => {
{
is_current_branch: true,
is_remote_branch: false,
name: 'master',
name: 'main',
upstream: '',
top_commit: '',
tag: ''
@@ -304,7 +304,7 @@ describe('Toolbar', () => {
{
is_current_branch: true,
is_remote_branch: false,
name: 'master',
name: 'main',
upstream: '',
top_commit: '',
tag: ''
4 changes: 2 additions & 2 deletions src/components/GitPanel.tsx
Original file line number Diff line number Diff line change
@@ -178,7 +178,7 @@ export class GitPanel extends React.Component<IGitPanelProps, IGitPanelState> {

this.state = {
branches: branches,
currentBranch: currentBranch ? currentBranch.name : 'master',
currentBranch: currentBranch ? currentBranch.name : 'main',
files: [],
remoteChangedFiles: [],
nCommitsAhead: 0,
@@ -265,7 +265,7 @@ export class GitPanel extends React.Component<IGitPanelProps, IGitPanelState> {
const { currentBranch } = this.props.model;

this.setState({
currentBranch: currentBranch ? currentBranch.name : 'master',
currentBranch: currentBranch ? currentBranch.name : 'main',
referenceCommit: null,
challengerCommit: null
});
8 changes: 4 additions & 4 deletions src/components/NewBranchDialog.tsx
Original file line number Diff line number Diff line change
@@ -240,7 +240,7 @@ export class NewBranchDialog extends React.Component<
itemKey={(index, data) => data[index].name}
itemSize={index => {
const branch = branches[index];
return [this.props.currentBranch, 'master', 'main'].includes(
return [this.props.currentBranch, 'main', 'main'].includes(
branch.name
)
? CURRENT_BRANCH_HEIGHT
@@ -268,9 +268,9 @@ export class NewBranchDialog extends React.Component<
} else if (b.name === current) {
return 1;
}
if (a.name === 'master') {
if (a.name === 'main') {
return -1;
} else if (b.name === 'master') {
} else if (b.name === 'main') {
return 1;
}
if (a.name === 'main') {
@@ -302,7 +302,7 @@ export class NewBranchDialog extends React.Component<
desc = this.props.trans.__(
'The current branch. Pick this if you want to build on work done in this branch.'
);
} else if (['master', 'main'].includes(branch.name)) {
} else if (['main', 'main'].includes(branch.name)) {
isBold = true;
desc = this.props.trans.__(
'The default branch. Pick this if you want to start fresh from the default branch.'
2 changes: 1 addition & 1 deletion ui-tests/README.md
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
This folder contains the integration tests of the extension.

They are defined using [Playwright](https://playwright.dev/docs/intro) test runner
and [Galata](https://github.com/jupyterlab/jupyterlab/tree/master/galata) helper.
and [Galata](https://github.com/jupyterlab/jupyterlab/tree/main/galata) helper.

The Playwright configuration is defined in [playwright.config.js](./playwright.config.js).

28 changes: 15 additions & 13 deletions ui-tests/tests/merge-commit.spec.ts
Original file line number Diff line number Diff line change
@@ -25,23 +25,23 @@ test.describe('Merge commit tests', () => {
test('should correctly display num files changed, insertions, and deletions', async ({
page
}) => {
const mergeCommit = await page.getByText("Merge branch 'sort-names'");
const mergeCommit = page.getByText("Merge branch 'sort-names'");

await mergeCommit.click();

const filesChanged = await mergeCommit.getByTitle('# Files Changed');
const insertions = await mergeCommit.getByTitle('# Insertions');
const deletions = await mergeCommit.getByTitle('# Deletions');
const filesChanged = mergeCommit.getByTitle('# Files Changed');
const insertions = mergeCommit.getByTitle('# Insertions');
const deletions = mergeCommit.getByTitle('# Deletions');

await filesChanged.waitFor();

await expect(await filesChanged.innerText()).toBe('3');
await expect(await insertions.innerText()).toBe('18240');
await expect(await deletions.innerText()).toBe('18239');
expect(await filesChanged.innerText()).toBe('3');
expect(await insertions.innerText()).toBe('18240');
expect(await deletions.innerText()).toBe('18239');
});

test('should correctly display files changed', async ({ page }) => {
const mergeCommit = await page.getByText("Merge branch 'sort-names'");
const mergeCommit = page.getByText("Merge branch 'sort-names'");

await mergeCommit.click();

@@ -57,7 +57,7 @@ test.describe('Merge commit tests', () => {
});

test('should diff file after clicking', async ({ page }) => {
const mergeCommit = await page.getByText("Merge branch 'sort-names'");
const mergeCommit = page.getByText("Merge branch 'sort-names'");

await mergeCommit.click();

@@ -72,22 +72,24 @@ test.describe('Merge commit tests', () => {
});

test('should revert merge commit', async ({ page }) => {
const mergeCommit = await page.getByText("Merge branch 'sort-names'");
const mergeCommit = page.getByText("Merge branch 'sort-names'", {
exact: true
});

await mergeCommit.click();
await page
.getByRole('button', { name: 'Revert changes introduced by this commit' })
.click();

const dialog = await page.getByRole('dialog');
const dialog = page.getByRole('dialog');
await dialog.waitFor({ state: 'visible' });

await expect(dialog).toBeTruthy();
expect(dialog).toBeTruthy();

await dialog.getByRole('button', { name: 'Submit' }).click();
await dialog.waitFor({ state: 'detached' });

const revertMergeCommit = await page
const revertMergeCommit = page
.locator('#jp-git-sessions')
.getByText("Revert 'Merge branch 'sort-names''");

0 comments on commit db7bd77

Please sign in to comment.