Skip to content

Commit

Permalink
refactor: Change the default branch
Browse files Browse the repository at this point in the history
  • Loading branch information
du5 committed Nov 25, 2020
1 parent a431418 commit 9fac74c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ deploy:
- **branch**: Optional git branch to deploy the static site to.
- Defaults to `gh-pages` on GitHub.
- Defaults to `coding-pages` on Coding.net.
- Otherwise defaults to `master`.
- Otherwise defaults to `main`.
- **token**: Optional token value to authenticate with the repo. Prefix with `$` to read token from environment variable (recommended). Repo must be a http(s) url. [More details](#deploy-with-token).
- **repo_name**: Unique name when deploying to multiple repositories.
* Example:
Expand Down Expand Up @@ -94,7 +94,7 @@ deploy:
deploy:
- type: git
repo: git@github.com:<username>/<username>.github.io.git
branch: master
branch: main
- type: git
repo: git@github.com:<username>/<username>.github.io.git
branch: src
Expand Down
6 changes: 3 additions & 3 deletions lib/parse_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function parseObjRepo(repo) {

return {
url: url,
branch: branch || 'master'
branch: branch || 'main'
};
}

Expand All @@ -52,7 +52,7 @@ function parseStrRepo(repo) {

return {
url: url,
branch: branch || 'master'
branch: branch || 'main'
};

}
Expand All @@ -65,7 +65,7 @@ function testBranch(repoUrl) {
const path = match[3];

if (host === 'github.com') {
branch = rGithubPage.test(path) ? 'master' : 'gh-pages';
branch = rGithubPage.test(path) ? 'main' : 'gh-pages';
} else if (host === 'coding.net') {
branch = 'coding-pages';
}
Expand Down
2 changes: 1 addition & 1 deletion test/deployer.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('deployer', () => {
});

function validate(branch) {
branch = branch || 'master';
branch = branch || 'main';

// Clone the remote repo
return spawn('git', ['clone', fakeRemote, validateDir, '--branch', branch]).then(() => {
Expand Down
12 changes: 6 additions & 6 deletions test/parse_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('parse config', () => {
});

result.should.eql([
{url: 'https://example.com/path/to/repo.git', branch: 'master'}
{url: 'https://example.com/path/to/repo.git', branch: 'main'}
]);
});

Expand Down Expand Up @@ -45,26 +45,26 @@ describe('parse config', () => {
});

result.should.eql([
{url: 'https://example.com/path/to/repo.git', branch: 'master'},
{url: 'https://example.com/path/to/repo.git', branch: 'main'},
{url: 'https://example.com/path/to/repo2.git', branch: 'custom'}
]);
});

it('github repo, master branch', () => {
it('github repo, main branch', () => {
// https
parseConfig({
repo: 'https://github.com/hexojs/hexojs.github.io.git'
})[0].branch.should.eql('master');
})[0].branch.should.eql('main');

// git
parseConfig({
repo: 'git://github.com/hexojs/hexojs.github.io.git'
})[0].branch.should.eql('master');
})[0].branch.should.eql('main');

// ssh
parseConfig({
repo: 'git@github.com:hexojs/hexojs.github.io.git'
})[0].branch.should.eql('master');
})[0].branch.should.eql('main');
});

it('github repo, gh-pages branch', () => {
Expand Down

0 comments on commit 9fac74c

Please sign in to comment.