Skip to content
Open
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
38 changes: 21 additions & 17 deletions build/Gruntfile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,10 @@ module.exports = (grunt) ->
grunt.file.setBase(path.resolve('..'))

# Options
[defaultChannel, releaseBranch] = getDefaultChannelAndReleaseBranch(packageJson.version)
installDir = grunt.option('install-dir')
buildDir = grunt.option('build-dir')
buildDir ?= path.join(os.tmpdir(), 'atom-build')
buildDir = path.resolve(buildDir)

channel = grunt.option('channel')
releasableBranches = ['stable', 'beta']
if process.env.APPVEYOR and not process.env.APPVEYOR_PULL_REQUEST_NUMBER
channel ?= process.env.APPVEYOR_REPO_BRANCH if process.env.APPVEYOR_REPO_BRANCH in releasableBranches

if process.env.TRAVIS and not process.env.TRAVIS_PULL_REQUEST
channel ?= process.env.TRAVIS_BRANCH if process.env.TRAVIS_BRANCH in releasableBranches

if process.env.JANKY_BRANCH
channel ?= process.env.JANKY_BRANCH if process.env.JANKY_BRANCH in releasableBranches

channel ?= 'dev'
buildDir = path.resolve(grunt.option('build-dir') ? path.join(os.tmpdir(), 'atom-build'))
channel = grunt.option('channel') ? defaultChannel

metadata = packageJson
appName = packageJson.productName
Expand Down Expand Up @@ -180,7 +167,7 @@ module.exports = (grunt) ->
pkg: grunt.file.readJSON('package.json')

atom: {
appName, channel, metadata,
appName, channel, metadata, releaseBranch,
appFileName, apmFileName,
appDir, buildDir, contentsDir, installDir, shellAppDir, symbolsDir,
}
Expand Down Expand Up @@ -301,3 +288,20 @@ module.exports = (grunt) ->
unless process.platform is 'linux' or grunt.option('no-install')
defaultTasks.push 'install'
grunt.registerTask('default', defaultTasks)

getDefaultChannelAndReleaseBranch = (version) ->
if version.match(/dev/) or isBuildingPR()
channel = 'dev'
releaseBranch = null
else
if version.match(/beta/)
channel = 'beta'
else
channel = 'stable'

minorVersion = version.match(/^\d\.\d/)[0]
releaseBranch = "#{minorVersion}-releases"
[channel, releaseBranch]

isBuildingPR = ->
process.env.APPVEYOR_PULL_REQUEST_NUMBER? or process.env.TRAVIS_PULL_REQUEST?
13 changes: 4 additions & 9 deletions build/tasks/publish-build-task.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,9 @@ module.exports = (gruntObject) ->
cp path.join(docsOutputDir, 'api.json'), path.join(buildDir, 'atom-api.json')

grunt.registerTask 'upload-assets', 'Upload the assets to a GitHub release', ->
channel = grunt.config.get('atom.channel')
switch channel
when 'stable'
isPrerelease = false
when 'beta'
isPrerelease = true
else
return
releaseBranch = grunt.config.get('atom.releaseBranch')
isPrerelease = grunt.config.get('atom.channel') is 'beta'
return unless releaseBranch?

doneCallback = @async()
startTime = Date.now()
Expand All @@ -55,7 +50,7 @@ module.exports = (gruntObject) ->

zipAssets buildDir, assets, (error) ->
return done(error) if error?
getAtomDraftRelease isPrerelease, channel, (error, release) ->
getAtomDraftRelease isPrerelease, releaseBranch, (error, release) ->
return done(error) if error?
assetNames = (asset.assetName for asset in assets)
deleteExistingAssets release, assetNames, (error) ->
Expand Down
4 changes: 1 addition & 3 deletions build/tasks/set-version-task.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ module.exports = (grunt) ->
{spawn} = require('./task-helpers')(grunt)

getVersion = (callback) ->
releasableBranches = ['stable', 'beta']
channel = grunt.config.get('atom.channel')
shouldUseCommitHash = if channel in releasableBranches then false else true
shouldUseCommitHash = grunt.config.get('atom.channel') is 'dev'
inRepository = fs.existsSync(path.resolve(__dirname, '..', '..', '.git'))
{version} = require(path.join(grunt.config.get('atom.appDir'), 'package.json'))
if shouldUseCommitHash and inRepository
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "atom",
"productName": "Atom",
"version": "1.5.1",
"version": "1.5.4",
"description": "A hackable text editor for the 21st Century.",
"main": "./src/browser/main.js",
"repository": {
Expand Down
30 changes: 30 additions & 0 deletions spec/git-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,36 @@ describe "GitRepository", ->
expect(repo.isStatusModified(status)).toBe false
expect(repo.isStatusNew(status)).toBe false

it 'caches the proper statuses when multiple project are open', ->
otherWorkingDirectory = copyRepository()

atom.project.setPaths([workingDirectory, otherWorkingDirectory])

waitsForPromise ->
atom.workspace.open('b.txt')

statusHandler = null
runs ->
repo = atom.project.getRepositories()[0]

statusHandler = jasmine.createSpy('statusHandler')
repo.onDidChangeStatuses statusHandler
repo.refreshStatus()

waitsFor ->
statusHandler.callCount > 0

runs ->
subDir = path.join(workingDirectory, 'dir')
fs.mkdirSync(subDir)

filePath = path.join(subDir, 'b.txt')
fs.writeFileSync(filePath, '')

status = repo.getCachedPathStatus(filePath)
expect(repo.isStatusModified(status)).toBe true
expect(repo.isStatusNew(status)).toBe false

describe "buffer events", ->
[editor] = []

Expand Down
78 changes: 0 additions & 78 deletions spec/package-manager-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -83,75 +83,6 @@ describe "PackageManager", ->

expect(loadedPackage.name).toBe "package-with-main"

it "registers any deserializers specified in the package's package.json", ->
pack = atom.packages.loadPackage("package-with-deserializers")

state1 = {deserializer: 'Deserializer1', a: 'b'}
expect(atom.deserializers.deserialize(state1)).toEqual {
wasDeserializedBy: 'Deserializer1'
state: state1
}

state2 = {deserializer: 'Deserializer2', c: 'd'}
expect(atom.deserializers.deserialize(state2)).toEqual {
wasDeserializedBy: 'Deserializer2'
state: state2
}

expect(pack.mainModule).toBeNull()

describe "when there are view providers specified in the package's package.json", ->
model1 = {worksWithViewProvider1: true}
model2 = {worksWithViewProvider2: true}

afterEach ->
atom.packages.deactivatePackage('package-with-view-providers')
atom.packages.unloadPackage('package-with-view-providers')

it "does not load the view providers immediately", ->
pack = atom.packages.loadPackage("package-with-view-providers")
expect(pack.mainModule).toBeNull()

expect(-> atom.views.getView(model1)).toThrow()
expect(-> atom.views.getView(model2)).toThrow()

it "registers the view providers when the package is activated", ->
pack = atom.packages.loadPackage("package-with-view-providers")

waitsForPromise ->
atom.packages.activatePackage("package-with-view-providers").then ->
element1 = atom.views.getView(model1)
expect(element1 instanceof HTMLDivElement).toBe true
expect(element1.dataset.createdBy).toBe 'view-provider-1'

element2 = atom.views.getView(model2)
expect(element2 instanceof HTMLDivElement).toBe true
expect(element2.dataset.createdBy).toBe 'view-provider-2'

it "registers the view providers when any of the package's deserializers are used", ->
pack = atom.packages.loadPackage("package-with-view-providers")

spyOn(atom.views, 'addViewProvider').andCallThrough()
atom.deserializers.deserialize({
deserializer: 'DeserializerFromPackageWithViewProviders',
a: 'b'
})
expect(atom.views.addViewProvider.callCount).toBe 2

atom.deserializers.deserialize({
deserializer: 'DeserializerFromPackageWithViewProviders',
a: 'b'
})
expect(atom.views.addViewProvider.callCount).toBe 2

element1 = atom.views.getView(model1)
expect(element1 instanceof HTMLDivElement).toBe true
expect(element1.dataset.createdBy).toBe 'view-provider-1'

element2 = atom.views.getView(model2)
expect(element2 instanceof HTMLDivElement).toBe true
expect(element2.dataset.createdBy).toBe 'view-provider-2'

it "registers the config schema in the package's metadata, if present", ->
pack = atom.packages.loadPackage("package-with-json-config-schema")
expect(atom.config.getSchema('package-with-json-config-schema')).toEqual {
Expand Down Expand Up @@ -180,15 +111,6 @@ describe "PackageManager", ->
beforeEach ->
mockLocalStorage()

it "defers loading the package's main module if the package previously used no Atom APIs when its main module was required", ->
pack1 = atom.packages.loadPackage('package-with-main')
expect(pack1.mainModule).toBeDefined()

atom.packages.unloadPackage('package-with-main')

pack2 = atom.packages.loadPackage('package-with-main')
expect(pack2.mainModule).toBeNull()

it "does not defer loading the package's main module if the package previously used Atom APIs when its main module was required", ->
pack1 = atom.packages.loadPackage('package-with-eval-time-api-calls')
expect(pack1.mainModule).toBeDefined()
Expand Down
3 changes: 1 addition & 2 deletions src/git-repository.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,7 @@ class GitRepository

relativeProjectPaths = @project?.getPaths()
.map (path) => @relativize(path)
.filter (path) -> path.length > 0
.map (path) -> path + '/**'
.map (path) -> if path.length > 0 then path + '/**' else '*'

@statusTask?.terminate()
@statusTask = Task.once @handlerPath, @getPath(), relativeProjectPaths, ({statuses, upstream, branch, submodules}) =>
Expand Down
10 changes: 1 addition & 9 deletions src/package.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ class Package
@loadKeymaps()
@loadMenus()
@loadStylesheets()
@loadDeserializers()
@configSchemaRegisteredOnLoad = @registerConfigSchemaFromMetadata()
@settingsPromise = @loadSettings()
if @shouldRequireMainModuleOnLoad() and not @mainModule?
Expand All @@ -94,13 +93,7 @@ class Package
this

shouldRequireMainModuleOnLoad: ->
not (
@metadata.deserializers? or
@metadata.viewProviders? or
@metadata.configSchema? or
@activationShouldBeDeferred() or
localStorage.getItem(@getCanDeferMainModuleRequireStorageKey()) is 'true'
)
not @activationShouldBeDeferred()

reset: ->
@stylesheets = []
Expand Down Expand Up @@ -131,7 +124,6 @@ class Package
try
@requireMainModule() unless @mainModule?
@configSchemaRegisteredOnActivate = @registerConfigSchemaFromMainModule()
@registerViewProviders()
@activateStylesheets()
if @mainModule? and not @mainActivated
@mainModule.activateConfig?()
Expand Down
4 changes: 2 additions & 2 deletions src/text-editor.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3197,7 +3197,7 @@ class TextEditor extends Model
# top of the visible area.
setFirstVisibleScreenRow: (screenRow, fromView) ->
unless fromView
maxScreenRow = @getLineCount() - 1
maxScreenRow = @getScreenLineCount() - 1
unless @config.get('editor.scrollPastEnd')
height = @displayBuffer.getHeight()
lineHeightInPixels = @displayBuffer.getLineHeightInPixels()
Expand All @@ -3215,7 +3215,7 @@ class TextEditor extends Model
height = @displayBuffer.getHeight()
lineHeightInPixels = @displayBuffer.getLineHeightInPixels()
if height? and lineHeightInPixels?
Math.min(@firstVisibleScreenRow + Math.floor(height / lineHeightInPixels), @getLineCount() - 1)
Math.min(@firstVisibleScreenRow + Math.floor(height / lineHeightInPixels), @getScreenLineCount() - 1)
else
null

Expand Down