mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Show commits ahead/behind upstream in status bar
This commit is contained in:
@@ -27,9 +27,11 @@ class Git
|
||||
ignore: 1 << 14
|
||||
|
||||
statuses: null
|
||||
upstream: null
|
||||
|
||||
constructor: (path, options={}) ->
|
||||
@statuses = {}
|
||||
@upstream = {ahead: 0, behind: 0}
|
||||
@repo = GitRepository.open(path)
|
||||
refreshOnWindowFocus = options.refreshOnWindowFocus ? true
|
||||
if refreshOnWindowFocus
|
||||
|
||||
@@ -9,8 +9,10 @@ module.exports =
|
||||
statuses = {}
|
||||
for path, status of repo.getRepo().getStatuses()
|
||||
statuses[fs.join(workingDirectoryPath, path)] = status
|
||||
upstream = repo.getAheadBehindCounts() ? {ahead: 0, behind: 0}
|
||||
repo.destroy()
|
||||
else
|
||||
upstream = {}
|
||||
statuses = {}
|
||||
|
||||
callTaskMethod('statusesLoaded', statuses)
|
||||
callTaskMethod('statusesLoaded', {statuses, upstream})
|
||||
|
||||
@@ -9,8 +9,9 @@ class RepositoryStatusTask extends Task
|
||||
started: ->
|
||||
@callWorkerMethod('loadStatuses', @repo.getPath())
|
||||
|
||||
statusesLoaded: (statuses) ->
|
||||
statusesLoaded: ({statuses, upstream}) ->
|
||||
@done()
|
||||
unless _.isEqual(statuses, @repo.statuses)
|
||||
@repo.statuses = statuses
|
||||
@repo.trigger 'statuses-changed'
|
||||
statusesUnchanged = _.isEqual(statuses, @repo.statuses) and _.isEqual(upstream, @repo.upstream)
|
||||
@repo.statuses = statuses
|
||||
@repo.upstream = upstream
|
||||
@repo.trigger 'statuses-changed' unless statusesUnchanged
|
||||
|
||||
@@ -17,6 +17,8 @@ class StatusBarView extends View
|
||||
@span class: 'git-branch', outlet: 'branchArea', =>
|
||||
@span class: 'octicons branch-icon'
|
||||
@span class: 'branch-label', outlet: 'branchLabel'
|
||||
@span class: 'octicons commits-ahead-label', outlet: 'commitsAhead'
|
||||
@span class: 'octicons commits-behind-label', outlet: 'commitsBehind'
|
||||
@span class: 'git-status', outlet: 'gitStatusIcon'
|
||||
@span class: 'file-info', =>
|
||||
@span class: 'current-path', outlet: 'currentPath'
|
||||
@@ -82,6 +84,16 @@ class StatusBarView extends View
|
||||
@gitStatusIcon.addClass('git-status octicons')
|
||||
return unless git?
|
||||
|
||||
if git.upstream.ahead > 0
|
||||
@commitsAhead.text(git.upstream.ahead).show()
|
||||
else
|
||||
@commitsAhead.hide()
|
||||
|
||||
if git.upstream.behind > 0
|
||||
@commitsBehind.text(git.upstream.behind).show()
|
||||
else
|
||||
@commitsBehind.hide()
|
||||
|
||||
status = git.statuses[path]
|
||||
if git.isStatusModified(status)
|
||||
@gitStatusIcon.addClass('modified-status-icon')
|
||||
|
||||
Reference in New Issue
Block a user