-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[build.webkit.org] Replace Trac with commitStore
rdar://118421383 https://bugs.webkit.org/show_bug.cgi?id=264842 Reviewed by Alexey Proskuryakov. Remove code using trac.webkit.org and replace it with a CommitStore based on commits.webkit.org which allows callers to both query for and store commit objects themselves. * Tools/CISupport/build-webkit-org/public_html/dashboard/Scripts/BuildbotIteration.js: (BuildbotIteration.prototype._deprecatedUpdateWithData): No need to propigate revision to Queue, it already has the revision data. * Tools/CISupport/build-webkit-org/public_html/dashboard/Scripts/BuildbotQueue.js: (BuildbotQueue.prototype.compareIterationsByRevisions): Use commitStore instead of trac object. (BuildbotQueue.prototype.updateIterationPosition): Deleted. * Tools/CISupport/build-webkit-org/public_html/dashboard/Scripts/BuildbotQueueView.js: (BuildbotQueueView.prototype._presentPopoverForRevisionRange): Use commitStore instead of trac object. (BuildbotQueueView.prototype._revisionContentWithPopoverForIteration): Ditto. * Tools/CISupport/build-webkit-org/public_html/dashboard/Scripts/CommitStore.js: Added. (CommitStore): Base class for all CommitSores. (CommitStore.prototype.update): Update cached commit information for all branches. (CommitStore.prototype.repr): Return the string representation of a commit. (CommitStore.prototype.startPeriodicUpdates): Periodically run the 'update' function. (CommitStore.prototype.uuidFor): Convert commit object to UUID integer for sorting. (CommitStore.prototype.addCommit): Add commit object to store. (CommitStore.prototype.branchPosition): Return an integer indicating what position a commit is on a branch. Note that for git repositories, this will be a position relative to the set of cached commits. (CommitStore.prototype.nextRevision): Return the next-oldest commit for a commit ref. (CommitStore.prototype.indexOfRef): Return local index of a specified commit. * Tools/CISupport/build-webkit-org/public_html/dashboard/Scripts/Commits.js: Removed. * Tools/CISupport/build-webkit-org/public_html/dashboard/Scripts/CommitsWebKitOrg.js: Added. (CommitsWebKitOrg.prototype.urlFor): Return commits.webkit.org URL for the specified ref. (CommitsWebKitOrg.prototype.fetch): Start processing of fetch specified number commits from specified ref. * Tools/CISupport/build-webkit-org/public_html/dashboard/Scripts/Initialization.js: Replace trac with commitStore. * Tools/CISupport/build-webkit-org/public_html/dashboard/Scripts/Main.js: Replace trac with commitStore. * Tools/CISupport/build-webkit-org/public_html/dashboard/Scripts/QueueView.js: (QueueView.prototype._appendPendingRevisionCount): Replace trac with commitStore, handle overflow from for relativel branch positions. (QueueView.prototype._popoverLinesForCommitRange): Consult commitStore to determine how to stringify a commit. (QueueView.prototype._presentPopoverForPendingCommits): Ditto. * Tools/CISupport/build-webkit-org/public_html/dashboard/Scripts/ResultsDatabase.js: (ResultsDatabase): Draft class to demonstrate how CommitStore protocol is extended. (ResultsDatabase.prototype.urlFor): Return results database URL for the specified ref. (ResultsDatabase.prototype.fetch): Start processing of fetch specified number commits from specified branch. * Tools/CISupport/build-webkit-org/public_html/dashboard/Scripts/Trac.js: Removed. * Tools/CISupport/build-webkit-org/public_html/dashboard/index.html: Remove Trac, include CommitStores. Canonical link: https://commits.webkit.org/270793@main
- Loading branch information
1 parent
82d979d
commit f7c26dc
Showing
12 changed files
with
367 additions
and
536 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
143 changes: 143 additions & 0 deletions
143
Tools/CISupport/build-webkit-org/public_html/dashboard/Scripts/CommitStore.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
/* | ||
* Copyright (C) 2022 Apple Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | ||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | ||
* THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
CommitStore = function() | ||
{ | ||
BaseObject.call(this); | ||
|
||
this.commitsByBranch = {'main': []}; | ||
this.indexForCommit = {}; | ||
this.commitsByRef = {}; | ||
this.useIdentifiers = false; | ||
}; | ||
|
||
BaseObject.addConstructorFunctions(CommitStore); | ||
|
||
CommitStore.UpdateInterval = 45000; // 45 seconds | ||
CommitStore.NO_MORE_REVISIONS = null; | ||
CommitStore.UUID_MULTIPLIER = 100; | ||
CommitStore.MAX_BLOCK = 20 | ||
|
||
CommitStore.Event = { | ||
CommitsUpdated: "commits-updated", | ||
}; | ||
|
||
CommitStore.prototype = { | ||
constructor: CommitStore, | ||
__proto__: BaseObject.prototype, | ||
|
||
update: function() { | ||
let self = this | ||
Object.entries(self.commitsByBranch).forEach(function(branch){ | ||
self.fetch(branch[0], CommitStore.MAX_BLOCK); | ||
}); | ||
}, | ||
repr: function(commit) { | ||
if (this.useIdentifiers && commit.identifier) | ||
return commit.identifier; | ||
if (commit.hash) | ||
return commit.hash; | ||
return null; | ||
}, | ||
startPeriodicUpdates: function() { | ||
this.update() | ||
this.updateTimer = setInterval(this.update.bind(this), CommitStore.UpdateInterval); | ||
}, | ||
uuidFor: function(data) { | ||
return data.timestamp * CommitStore.UUID_MULTIPLIER + data.order; | ||
}, | ||
addCommit: function(commit) { | ||
if (this.useIdentifiers) | ||
this.commitsByRef[commit.identifier] = commit; | ||
this.commitsByRef[commit.hash] = commit; | ||
|
||
if (!this.commitsByBranch[commit.branch]) | ||
this.commitsByBranch[commit.branch] = []; | ||
|
||
let index = 0; | ||
let didInsert = false; | ||
while (true) { | ||
let currentValue = this.commitsByBranch[commit.branch][index]; | ||
if (currentValue && this.uuidFor(commit) == this.uuidFor(currentValue)) | ||
didInsert = true; | ||
else if (!didInsert && (!currentValue || this.uuidFor(commit) > this.uuidFor(currentValue))) { | ||
this.commitsByBranch[commit.branch] = [ | ||
...this.commitsByBranch[commit.branch].slice(0, index), | ||
commit, | ||
...this.commitsByBranch[commit.branch].slice(index) | ||
]; | ||
currentValue = commit; | ||
didInsert = true; | ||
} else if (!currentValue) { | ||
if (didInsert) | ||
this.dispatchEventToListeners(CommitStore.Event.CommitsUpdated, null); | ||
return; | ||
} | ||
|
||
if (this.useIdentifiers) | ||
this.indexForCommit[currentValue.identifier] = index; | ||
this.indexForCommit[currentValue.hash] = index; | ||
index += 1; | ||
} | ||
}, | ||
branchPosition: function(ref) { | ||
data = this.commitsByRef[ref]; | ||
|
||
if (!this.useIdentifiers) { | ||
// Git repositories without identifiers can't give an absolute branch position | ||
// instead, compute branch position relative to the set of commits we're aware of | ||
const result = this.indexForCommit[ref]; | ||
if (result == null || !data) | ||
return null; | ||
return this.commitsByBranch[data.branch].length - result; | ||
} | ||
|
||
let identifierParts = ref.split('@'); | ||
if (data) | ||
identifierParts = data.identifier.split('@'); | ||
|
||
if (identifierParts.length <= 1) | ||
return null; | ||
const identifierCount = identifierParts[0].split('.'); | ||
if (identifierCount.length == 1) | ||
return Number(identifierCount[0]); | ||
else if (identifierCount.length == 2) | ||
return Number(identifierCount[1]); | ||
return null | ||
}, | ||
nextRevision: function(branchName, revision) { | ||
const index = this.indexOfRef(revision); | ||
if (index < 0) | ||
return CommitStore.NO_MORE_REVISIONS; | ||
const commitsOnBranch = this.commitsByBranch[branchName]; | ||
if (commitsOnBranch && index + 1 < commitsOnBranch.length) | ||
return commitsOnBranch[index + 1].identifier; | ||
return CommitStore.NO_MORE_REVISIONS; | ||
}, | ||
indexOfRef: function(ref) { | ||
const result = this.indexForCommit[ref]; | ||
return result == null ? -1 : result; | ||
}, | ||
}; |
Oops, something went wrong.