Skip to content
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

Rename master branch to main #479

Merged
merged 2 commits into from
Feb 6, 2022
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
2 changes: 1 addition & 1 deletion app/actors/Actors.scala
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class DocumentationConfigProvider @Inject()(environment: Environment, configurat
for {
file <- config.getOptional[String]("versionFile")
pattern <- config.getOptional[String]("versionPattern")
} yield MasterVersion(file, pattern.r),
} yield MainVersion(file, pattern.r),
config.getOptional[String]("gitHubSource"),
)
}
Expand Down
30 changes: 15 additions & 15 deletions app/actors/DocumentationPollingActor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ class DocumentationPollingActor(
}

/**
* Determining the master version of the repo means looking up the master branch, if found, loading a configured
* master version file out of it, running a configured regular expression against that file to extract the version,
* Determining the main version of the repo means looking up the main branch, if found, loading a configured
* main version file out of it, running a configured regular expression against that file to extract the version,
* and if found, returning that version and the hash of the repo it comes from.
*/
private def determineMasterVersion(repo: DocumentationGitRepo): Option[(Version, ObjectId)] = {
private def determineMainVersion(repo: DocumentationGitRepo): Option[(Version, ObjectId)] = {
def fileContents(hash: ObjectId, file: String): Option[String] = {
repo.repo.loadFile(hash, file).map {
case (size, is) =>
Expand All @@ -86,12 +86,12 @@ class DocumentationPollingActor(
}

for {
masterVersion <- repo.config.masterVersion
masterHash <- repo.repo.hashForRef("master")
contents <- fileContents(masterHash, masterVersion.file)
matched <- masterVersion.pattern.findFirstMatchIn(contents)
mainVersion <- repo.config.mainVersion
mainHash <- repo.repo.hashForRef("main")
contents <- fileContents(mainHash, mainVersion.file)
matched <- mainVersion.pattern.findFirstMatchIn(contents)
version <- Version.parse(matched.group(1).replace("-SNAPSHOT", ".x"))
} yield version -> masterHash
} yield version -> mainHash
}

private def scanAndSendDocumentation(old: Option[Documentation]): Documentation = {
Expand All @@ -103,15 +103,15 @@ class DocumentationPollingActor(
.filter(_._1.matches("""\d+\.\d+\.x""")),
)).map(v => (v._1, v._2.name, repos.default.repo.fileRepoForHash(v._2), v._1.name))

// Find the master version
val defaultMasterVersion = determineMasterVersion(repos.default).flatMap {
// Find the main version
val defaultMainVersion = determineMainVersion(repos.default).flatMap {
case (version, hash) if defaultVersions.forall(_._1 != version) =>
val repo = repos.default.repo.fileRepoForHash(hash)
Some((version, hash.name, repo, "master"))
Some((version, hash.name, repo, "main"))
case _ => None
}

val allVersions = (defaultVersions ++ defaultMasterVersion).toList.sortBy(_._1).reverse.map {
val allVersions = (defaultVersions ++ defaultMainVersion).toList.sortBy(_._1).reverse.map {
case (version, cacheId, repo, symName) =>
val newCacheId = xorHashes(cacheId, utils.SiteVersion.hash)

Expand Down Expand Up @@ -142,18 +142,18 @@ class DocumentationPollingActor(

// Now for each translation
val translations = repos.translations.map { t =>
// Parse all the versions from tags, branches and the master version
// Parse all the versions from tags, branches and the main version
val gitTags = parseVersionsFromRefs(t.repo.allTags).map(v => (v._1, v._2, v._1.name))
val gitBranches = parseVersionsFromRefs(
t.repo.allBranches
.filter(_._1.matches("""\d+\.\d+\.x""")),
).map(v => (v._1, v._2, v._1.name))
val masterVersion = determineMasterVersion(t).map(v => (v._1, v._2, "master"))
val mainVersion = determineMainVersion(t).map(v => (v._1, v._2, "main"))

implicit val lang = t.config.lang
val versions = versionsToTranslations(
t.repo,
gitTags ++ gitBranches ++ masterVersion,
gitTags ++ gitBranches ++ mainVersion,
defaultTranslation,
old.flatMap(_.translations.get(lang)),
)
Expand Down
4 changes: 2 additions & 2 deletions app/models/documentation/Config.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ case class TranslationConfig(
repo: File,
basePath: Option[String],
remote: String,
masterVersion: Option[MasterVersion],
mainVersion: Option[MainVersion],
gitHubSource: Option[String],
)

case class MasterVersion(file: String, pattern: Regex)
case class MainVersion(file: String, pattern: Regex)
2 changes: 1 addition & 1 deletion app/services/modules/InMemDatabase.scala
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ object InMemDatabase {
parseRelease(793, "1.2", "0", "2012-03-10 08:20:07", "1.2.5a", 42),
parseRelease(794, "1.2.4", "", "2012-03-10 23:19:27", "0.2", 122),
parseRelease(795, "1.2.x", "0", "2012-03-11 09:48:58", "0.9.3.2", 14),
parseRelease(796, "master", "0", "2012-03-11 18:22:28", "2.5", 7),
parseRelease(796, "main", "0", "2012-03-11 18:22:28", "2.5", 7),
parseRelease(797, "1.2.4", "0", "2012-03-12 10:53:42", "0.2.0", 136),
parseRelease(799, "*", "0", "2012-03-20 12:04:18", "0.9.5", 137),
parseRelease(800, "*", "0", "2012-03-20 12:42:01", "0.9.3.4", 14),
Expand Down
2 changes: 1 addition & 1 deletion app/utils/GitFileRepository.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class PlayGitRepository(val gitDir: File, val remote: String = "origin", basePat
// Perform two fetches. The first fetch will remove deleted refs, the second fetch
// doesn't remove anything. We need to run the second fetch because the JGit code
// for removing deleted remote refs is buggy so the first fetch will remove the
// remote master branch if it's already present. The second fetch will restore it.
// remote main branch if it's already present. The second fetch will restore it.
// The second fetch should be pretty lightweight to run again because there shouldn't
// be much data that needs pulling down.
git.fetch().setTagOpt(TagOpt.FETCH_TAGS).setRemoveDeletedRefs(true).setRemote(remote).call()
Expand Down
6 changes: 3 additions & 3 deletions app/views/blog/socketio.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ <h2 id="akka-streams-based">Akka streams based</h2>
<p>play-socket.io is built on <a href="http://doc.akka.io/docs/akka/snapshot/scala/stream/index.html">Akka streams</a>. Each socket.io namespace is handled by an Akka streams <code>Flow</code>, which takes at its inlet the stream of messages for that namespace coming from the client, and emits messages to go to the client.</p>
<p>One advantage of using Akka streams is that backpressure comes for free. This is an important feature for protecting servers from being overwhelmed with events. Without backpressure, there&#39;s no way for the server to tell the client to stop sending messages, so the server has to either process them, exhausting itself of CPU and other resources, or buffer them, and risk running out of memory. However play-socket.io will push back on the TCP connection when it can&#39;t keep up with rate of messages being sent from the client, preventing the client from sending any further messages. Likewise, backpressure from slow consuming clients gets pushed back to the source of Akka streams flows, ensuring a server will slow down its emission of messages and won&#39;t run out of memory buffering the messages that are yet to be consumed by the client.</p>
<h2 id="built-in-clustering">Built-in clustering</h2>
<p>Being built on Akka, play-socket.io does not need a sticky load balancer or any intelligent routing to serve socket.io endpoints. In most other socket.io implementations, if you have a socket.io endpoint served by a cluster of servers, you need to ensure that requests for the same engine.io session always get routed to the same node. With play-socket.io, requests can be handled by any node, and Akka clustering is used to ensure that they get routed to the right node. This allows the use of dumb, stateless load balancers, simplifying your deployment. The clustered chat example app in <a href="https://github.com/playframework/play-socket.io/tree/master/samples/scala/clustered-chat">Scala</a> and <a href="https://github.com/playframework/play-socket.io/tree/master/samples/java/clustered-chat">Java</a> shows how to configure play-socket.io to work in a multi node environment, and even comes with a handy script to start 3 nodes behind an nginx load balancer to demonstrate the multi node setup at work.</p>
<p>Detailed documentation on using play-socket.io in a clustered setup can be found in the <a href="https://github.com/playframework/play-socket.io/blob/master/docs/ScalaSocketIO.md#multi-node-setup">Scala</a> and <a href="https://github.com/playframework/play-socket.io/blob/master/docs/JavaSocketIO.md#multi-node-setup">Java</a> documentation.</p>
<p>Being built on Akka, play-socket.io does not need a sticky load balancer or any intelligent routing to serve socket.io endpoints. In most other socket.io implementations, if you have a socket.io endpoint served by a cluster of servers, you need to ensure that requests for the same engine.io session always get routed to the same node. With play-socket.io, requests can be handled by any node, and Akka clustering is used to ensure that they get routed to the right node. This allows the use of dumb, stateless load balancers, simplifying your deployment. The clustered chat example app in <a href="https://github.com/playframework/play-socket.io/tree/main/samples/scala/clustered-chat">Scala</a> and <a href="https://github.com/playframework/play-socket.io/tree/main/samples/java/clustered-chat">Java</a> shows how to configure play-socket.io to work in a multi node environment, and even comes with a handy script to start 3 nodes behind an nginx load balancer to demonstrate the multi node setup at work.</p>
<p>Detailed documentation on using play-socket.io in a clustered setup can be found in the <a href="https://github.com/playframework/play-socket.io/blob/main/docs/ScalaSocketIO.md#multi-node-setup">Scala</a> and <a href="https://github.com/playframework/play-socket.io/blob/main/docs/JavaSocketIO.md#multi-node-setup">Java</a> documentation.</p>
<h2 id="example-code">Example code</h2>
<p>Here&#39;s a minimal chat engine (similar to the <a href="https://socket.io/get-started/chat/">official socket.io chat example</a>) written in Play Scala:</p>
<pre><code class="lang-scala">import akka<span class="hljs-selector-class">.stream</span><span class="hljs-selector-class">.Materializer</span>
Expand Down Expand Up @@ -60,7 +60,7 @@ <h2 id="example-code">Example code</h2>
POST /socket.io/ play<span class="hljs-selector-class">.engineio</span><span class="hljs-selector-class">.EngineIOController</span><span class="hljs-selector-class">.endpoint</span>(transport)
</code></pre><p>And that&#39;s all!</p>
<h2 id="documentation-and-samples">Documentation and samples</h2>
<p>For installation instructions, comprehensive documentation and links to sample apps, see the documentation for <a href="https://github.com/playframework/play-socket.io/blob/master/docs/ScalaSocketIO.md">Scala</a> and <a href="https://github.com/playframework/play-socket.io/blob/master/docs/JavaSocketIO.md">Java</a>. To contribute, visit the projects <a href="https://github.com/playframework/play-socket.io">GitHub page</a>.</p>
<p>For installation instructions, comprehensive documentation and links to sample apps, see the documentation for <a href="https://github.com/playframework/play-socket.io/blob/main/docs/ScalaSocketIO.md">Scala</a> and <a href="https://github.com/playframework/play-socket.io/blob/main/docs/JavaSocketIO.md">Java</a>. To contribute, visit the projects <a href="https://github.com/playframework/play-socket.io">GitHub page</a>.</p>


</article>
Expand Down
4 changes: 2 additions & 2 deletions public/markdown/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ Before making a contribution, it is important to make sure that the change you w
3. Ensure that your commits are squashed. See [working with git](/documentation/latest/WorkingWithGit) for more information.
4. Submit a pull request.

If the pull request does not meet the above requirements then the code should **not** be merged into master, or even reviewed - regardless of how good or important it is. No exceptions.
If the pull request does not meet the above requirements then the code should **not** be merged into main, or even reviewed - regardless of how good or important it is. No exceptions.

The pull request will be reviewed according to the [implementation decision process](community-process#Implementation-decisions).

## Backporting policy

Generally, all bug fixes, improvements and new features will go to the master branch. Backports and other commits to stable branches will only be accepted if they meet the following conditions:
Generally, all bug fixes, improvements and new features will go to the main branch. Backports and other commits to stable branches will only be accepted if they meet the following conditions:

* The change only affects the documentation
* The change fixes a regression that was introduced in a previous stable release from that branch
Expand Down
4 changes: 2 additions & 2 deletions test/resources/github/repos.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"forks": 2025,
"open_issues": 248,
"watchers": 5554,
"default_branch": "master",
"default_branch": "main",
"permissions": {
"admin": true,
"push": true,
Expand Down Expand Up @@ -176,7 +176,7 @@
"forks": 10,
"open_issues": 4,
"watchers": 7,
"default_branch": "master",
"default_branch": "main",
"permissions": {
"admin": true,
"push": true,
Expand Down
4 changes: 2 additions & 2 deletions test/utils/GitFileRepositorySpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class GitFileRepositorySpec extends Specification {
FileUtils.write(new File(repodir, "framework/build.sbt"), "Build", encoding)

// Turn it into a git repo
val repo = new InitCommand().setDirectory(repodir).call()
val repo = new InitCommand().setInitialBranch("main").setDirectory(repodir).call()

val author = new PersonIdent("Unit Test", "unit.test@example.org")

Expand Down Expand Up @@ -64,7 +64,7 @@ class GitFileRepositorySpec extends Specification {

def withGitRepo[T](block: GitFileRepository => T): T = withPlayRepo { playRepo =>
val gitRepo =
new GitFileRepository(playRepo, playRepo.hashForRef("master").orNull, Some("documentation/manual"))
new GitFileRepository(playRepo, playRepo.hashForRef("main").orNull, Some("documentation/manual"))
block(gitRepo)
}

Expand Down