Rename default branch from `master` to `main` (#4116)

This commit is contained in:
JP Simard 2022-09-01 07:09:46 -04:00 committed by GitHub
parent e0f23fa8e9
commit ea41b9fd09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 48 additions and 48 deletions

View File

@ -3,7 +3,7 @@ name: docker
on:
push:
branches:
- master
- main
tags:
- '*'

View File

@ -3,7 +3,7 @@ author: JP Simard, SwiftLint Contributors
author_url: https://jpsim.com
root_url: https://realm.github.io/SwiftLint/
github_url: https://github.com/realm/SwiftLint
github_file_prefix: https://github.com/realm/SwiftLint/tree/master
github_file_prefix: https://github.com/realm/SwiftLint/tree/main
swift_build_tool: spm
theme: fullwidth
clean: true

View File

@ -1,6 +1,6 @@
## Master
## Main
_Note: The default branch for the SwiftLint git repository will be renamed from
_Note: The default branch for the SwiftLint git repository was renamed from
`master` to `main` on September 1st. Please update any code or automation
accordingly._

View File

@ -1,8 +1,8 @@
## Pull Requests
All changes, no matter how trivial, must be done via pull request. Commits
should never be made directly on the `master` branch. Prefer rebasing over
merging `master` into your PR branch to update it and resolve conflicts.
should never be made directly on the `main` branch. Prefer rebasing over
merging `main` into your PR branch to update it and resolve conflicts.
_If you have commit access to SwiftLint and believe your change to be trivial
and not worth waiting for review, you may open a pull request and merge
@ -98,11 +98,11 @@ configuration object via the `configuration` property:
* If none of the provided `RuleConfiguration`s are applicable, you can create one
specifically for your rule.
See [`ForceCastRule`](https://github.com/realm/SwiftLint/blob/master/Source/SwiftLintFramework/Rules/Idiomatic/ForceCastRule.swift)
See [`ForceCastRule`](https://github.com/realm/SwiftLint/blob/main/Source/SwiftLintFramework/Rules/Idiomatic/ForceCastRule.swift)
for a rule that allows severity configuration,
[`FileLengthRule`](https://github.com/realm/SwiftLint/blob/master/Source/SwiftLintFramework/Rules/Metrics/FileLengthRule.swift)
[`FileLengthRule`](https://github.com/realm/SwiftLint/blob/main/Source/SwiftLintFramework/Rules/Metrics/FileLengthRule.swift)
for a rule that has multiple severity levels,
[`IdentifierNameRule`](https://github.com/realm/SwiftLint/blob/master/Source/SwiftLintFramework/Rules/Style/IdentifierNameRule.swift)
[`IdentifierNameRule`](https://github.com/realm/SwiftLint/blob/main/Source/SwiftLintFramework/Rules/Style/IdentifierNameRule.swift)
for a rule that allows name evaluation configuration:
``` yaml

View File

@ -20,7 +20,7 @@ has_bazel_changes = !modified_files.grep(/WORKSPACE|bazel\/|BUILD/).empty?
# Add a CHANGELOG entry for app changes
if !modified_files.include?('CHANGELOG.md') && has_app_changes
warn("If this is a user-facing change, please include a CHANGELOG entry to credit yourself! \nYou can find it at [CHANGELOG.md](https://github.com/realm/SwiftLint/blob/master/CHANGELOG.md).")
warn("If this is a user-facing change, please include a CHANGELOG entry to credit yourself! \nYou can find it at [CHANGELOG.md](https://github.com/realm/SwiftLint/blob/main/CHANGELOG.md).")
markdown <<-MARKDOWN
Here's an example of your CHANGELOG entry:
```markdown

View File

@ -176,7 +176,7 @@ ifneq ($(strip $(shell git status --untracked-files=no --porcelain 2>/dev/null))
endif
$(eval NEW_VERSION_AND_NAME := $(filter-out $@,$(MAKECMDGOALS)))
$(eval NEW_VERSION := $(shell echo $(NEW_VERSION_AND_NAME) | sed 's/:.*//' ))
@sed -i '' 's/## Master/## $(NEW_VERSION_AND_NAME)/g' CHANGELOG.md
@sed -i '' 's/## Main/## $(NEW_VERSION_AND_NAME)/g' CHANGELOG.md
@sed 's/__VERSION__/$(NEW_VERSION)/g' tools/Version.swift.template > Source/SwiftLintFramework/Models/Version.swift
git commit -a -m "release $(NEW_VERSION)"
git tag -a $(NEW_VERSION) -m "$(NEW_VERSION_AND_NAME)"

View File

@ -7,8 +7,8 @@ SwiftLint hooks into [Clang](http://clang.llvm.org) and
[AST](http://clang.llvm.org/docs/IntroductionToTheClangAST.html) representation
of your source files for more accurate results.
[![Build Status](https://dev.azure.com/jpsim/SwiftLint/_apis/build/status/realm.SwiftLint?branchName=master)](https://dev.azure.com/jpsim/SwiftLint/_build/latest?definitionId=4?branchName=master)
[![codecov.io](https://codecov.io/github/realm/SwiftLint/coverage.svg?branch=master)](https://codecov.io/github/realm/SwiftLint?branch=master)
[![Build Status](https://dev.azure.com/jpsim/SwiftLint/_apis/build/status/realm.SwiftLint?branchName=main)](https://dev.azure.com/jpsim/SwiftLint/_build/latest?definitionId=4?branchName=main)
[![codecov.io](https://codecov.io/github/realm/SwiftLint/coverage.svg?branch=main)](https://codecov.io/github/realm/SwiftLint?branch=main)
![](assets/screenshot.png)
@ -16,7 +16,7 @@ This project adheres to the [Contributor Covenant Code of Conduct](https://realm
By participating, you are expected to uphold this code. Please report
unacceptable behavior to [info@realm.io](mailto:info@realm.io).
> Language Switch: [中文](https://github.com/realm/SwiftLint/blob/master/README_CN.md), [한국어](https://github.com/realm/SwiftLint/blob/master/README_KR.md).
> Language Switch: [中文](https://github.com/realm/SwiftLint/blob/main/README_CN.md), [한국어](https://github.com/realm/SwiftLint/blob/main/README_KR.md).
## Installation
@ -349,7 +349,7 @@ continues to contribute more over time.
You can find an updated list of rules and more information about them
[here](https://realm.github.io/SwiftLint/rule-directory.html).
You can also check [Source/SwiftLintFramework/Rules](https://github.com/realm/SwiftLint/tree/master/Source/SwiftLintFramework/Rules)
You can also check [Source/SwiftLintFramework/Rules](https://github.com/realm/SwiftLint/tree/main/Source/SwiftLintFramework/Rules)
directory to see their implementation.
### Opt-In Rules

View File

@ -4,8 +4,8 @@ SwiftLint 是一个用于强制检查 Swift 代码风格和规定的一个工具
SwiftLint Hook 了 [Clang](http://clang.llvm.org) 和 [SourceKit](http://www.jpsim.com/uncovering-sourcekit) 从而能够使用 [AST](http://clang.llvm.org/docs/IntroductionToTheClangAST.html) 来表示源代码文件的更多精确结果。
[![Build Status](https://dev.azure.com/jpsim/SwiftLint/_apis/build/status/realm.SwiftLint?branchName=master)](https://dev.azure.com/jpsim/SwiftLint/_build/latest?definitionId=4?branchName=master)
[![codecov.io](https://codecov.io/github/realm/SwiftLint/coverage.svg?branch=master)](https://codecov.io/github/realm/SwiftLint?branch=master)
[![Build Status](https://dev.azure.com/jpsim/SwiftLint/_apis/build/status/realm.SwiftLint?branchName=main)](https://dev.azure.com/jpsim/SwiftLint/_build/latest?definitionId=4?branchName=main)
[![codecov.io](https://codecov.io/github/realm/SwiftLint/coverage.svg?branch=main)](https://codecov.io/github/realm/SwiftLint?branch=main)
![](assets/screenshot.png)

View File

@ -4,8 +4,8 @@ SwiftLint는 스위프트 스타일 및 컨벤션을 강제하기 위한 도구
SwiftLint는 좀 더 정확한 결과를 위해 [Clang](http://clang.llvm.org)과 [SourceKit](http://www.jpsim.com/uncovering-sourcekit)에 연결하여 소스 파일의 [AST](http://clang.llvm.org/docs/IntroductionToTheClangAST.html) 표현을 사용합니다.
[![Build Status](https://dev.azure.com/jpsim/SwiftLint/_apis/build/status/realm.SwiftLint?branchName=master)](https://dev.azure.com/jpsim/SwiftLint/_build/latest?definitionId=4?branchName=master)
[![codecov.io](https://codecov.io/github/realm/SwiftLint/coverage.svg?branch=master)](https://codecov.io/github/realm/SwiftLint?branch=master)
[![Build Status](https://dev.azure.com/jpsim/SwiftLint/_apis/build/status/realm.SwiftLint?branchName=main)](https://dev.azure.com/jpsim/SwiftLint/_build/latest?definitionId=4?branchName=main)
[![codecov.io](https://codecov.io/github/realm/SwiftLint/coverage.svg?branch=main)](https://codecov.io/github/realm/SwiftLint?branch=main)
![](assets/screenshot.png)

View File

@ -1,5 +1,5 @@
trigger:
- master
- main
jobs:
- job: Sourcery
@ -121,9 +121,9 @@ jobs:
artifactName: 'API Docs'
targetPath: 'docs'
- task: DownloadSecureFile@1
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')
inputs:
secureFile: doc_deploy_key
- script: ./tools/push-docs
displayName: Publish
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')

View File

@ -21,7 +21,7 @@ require 'erb'
}
OptionParser.new do |opts|
opts.on('--branch BRANCH', "compares the performance of BRANCH against 'master'") do |branch|
opts.on('--branch BRANCH', "compares the performance of BRANCH against 'main'") do |branch|
@options[:branch] = branch
end
opts.on('--iterations N', Integer, 'iterates lint N times on each repositories') do |iterations|
@ -45,8 +45,8 @@ class Repo
attr_accessor :commit_hash
attr_accessor :branch_exit_value
attr_accessor :branch_duration
attr_accessor :master_exit_value
attr_accessor :master_duration
attr_accessor :main_exit_value
attr_accessor :main_duration
def initialize(name, github_location)
@name = name
@ -62,16 +62,16 @@ class Repo
end
def duration_report
percent_change = 100 * (@master_duration - @branch_duration) / @master_duration
percent_change = 100 * (@main_duration - @branch_duration) / @main_duration
faster_slower = nil
if @branch_duration < @master_duration
if @branch_duration < @main_duration
faster_slower = 'faster'
else
faster_slower = 'slower'
percent_change *= -1
end
"Linting #{self} with this PR took #{@branch_duration}s " \
"vs #{@master_duration}s on master (#{percent_change.to_i}\% #{faster_slower})"
"vs #{@main_duration}s on main (#{percent_change.to_i}\% #{faster_slower})"
end
end
@ -105,14 +105,14 @@ def perform(*args)
end
def validate_state_to_run
if `git symbolic-ref HEAD --short || true`.strip == 'master' && @options[:branch] == 'HEAD'
fail "can't run osscheck without '--branch' option from 'master' as the script compares " \
"the performance of this branch against 'master'"
if `git symbolic-ref HEAD --short || true`.strip == 'main' && @options[:branch] == 'HEAD'
fail "can't run osscheck without '--branch' option from 'main' as the script compares " \
"the performance of this branch against 'main'"
end
end
def make_directory_structure
['branch_reports', 'master_reports'].each do |dir|
['branch_reports', 'main_reports'].each do |dir|
FileUtils.mkdir_p("#{@working_dir}/#{dir}")
end
end
@ -174,7 +174,7 @@ def generate_reports(branch)
if branch == 'branch'
repo.branch_exit_value = wait_thr.value
else
repo.master_exit_value = wait_thr.value
repo.main_exit_value = wait_thr.value
end
end
end
@ -191,7 +191,7 @@ def generate_reports(branch)
if branch == 'branch'
repo.branch_duration = average_duration
else
repo.master_duration = average_duration
repo.main_duration = average_duration
end
end
end
@ -201,7 +201,7 @@ def build(branch)
puts "Building #{branch}"
dir = "#{@working_dir}/builds"
target = branch == 'master' ? @effective_master_commitish : @options[:branch]
target = branch == 'main' ? @effective_main_commitish : @options[:branch]
if File.directory?(dir)
perform("cd #{dir}; git checkout #{target}")
else
@ -227,22 +227,22 @@ def diff_and_report_changes_to_danger
@repos.each { |repo| message repo.duration_report }
@repos.each do |repo|
if repo.master_exit_value != repo.branch_exit_value
if repo.main_exit_value != repo.branch_exit_value
warn "This PR changed the exit value when running on #{repo.name}: " \
"(#{repo.master_exit_value} to #{repo.branch_exit_value})"
"(#{repo.main_exit_value} to #{repo.branch_exit_value})"
# If the exit value changed, don't show the fixes or regressions for this
# repo because it's likely due to a crash, and all violations would be noisy
next
end
branch = non_empty_lines("#{@working_dir}/branch_reports/#{repo.name}.txt").sort
master = non_empty_lines("#{@working_dir}/master_reports/#{repo.name}.txt").sort
main = non_empty_lines("#{@working_dir}/main_reports/#{repo.name}.txt").sort
(master - branch).each do |fixed|
(main - branch).each do |fixed|
escaped_message = ERB::Util.html_escape remove_base_path(repo, fixed)
message "This PR fixed a violation in #{repo.name}: [#{escaped_message}](#{convert_to_link(repo, fixed)})"
end
(branch - master).each do |violation|
(branch - main).each do |violation|
escaped_message = ERB::Util.html_escape remove_base_path(repo, violation)
warn "This PR introduced a violation in #{repo.name}: [#{escaped_message}](#{convert_to_link(repo, violation)})"
end
@ -259,8 +259,8 @@ def clean_up
end
def set_globals
@effective_master_commitish = `git merge-base origin/master #{@options[:branch]}`.chomp
@changed_swift_files = `git diff --diff-filter=AMRCU #{@effective_master_commitish} --name-only | grep "\.swift$" || true`.split("\n")
@effective_main_commitish = `git merge-base origin/main #{@options[:branch]}`.chomp
@changed_swift_files = `git diff --diff-filter=AMRCU #{@effective_main_commitish} --name-only | grep "\.swift$" || true`.split("\n")
@changed_rule_files = @changed_swift_files.select do |file|
file.start_with? 'Source/SwiftLintFramework/Rules/'
end
@ -313,16 +313,16 @@ set_globals
print_rules_changed
make_directory_structure
# Build & generate reports for branch & master
%w[branch master].each do |branch|
# Build & generate reports for branch & main
%w[branch main].each do |branch|
build(branch)
end
full_version_branch = `#{@working_dir}/builds/swiftlint-branch version --verbose`
full_version_master = `#{@working_dir}/builds/swiftlint-master version --verbose`
full_version_main = `#{@working_dir}/builds/swiftlint-main version --verbose`
if full_version_branch == full_version_master
message "Skipping OSSCheck because SwiftLint hasn't changed compared to 'master'"
if full_version_branch == full_version_main
message "Skipping OSSCheck because SwiftLint hasn't changed compared to 'main'"
# Clean up
clean_up unless @options[:skip_clean]
exit
@ -330,7 +330,7 @@ end
setup_repos
%w[branch master].each do |branch|
%w[branch main].each do |branch|
generate_reports(branch)
end