Skip to content

Commit

Permalink
Loading initial sample code
Browse files Browse the repository at this point in the history
  • Loading branch information
willsmythe committed Apr 28, 2015
1 parent fd4d78b commit 583ca6b
Show file tree
Hide file tree
Showing 138 changed files with 27,651 additions and 0 deletions.
23 changes: 23 additions & 0 deletions branch-delete/extension.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"namespace": "samples.branch-delete",
"version": "0.0.1",
"name": "Branch Delete (Sample)",
"description": "Clean up old or unneeded Git branches right from within Visual Studio Online.",
"provider": {
"name": "Microsoft and the community"
},
"icon": "https://localhost/images/fabrikam-logo.png",
"baseUri": "https://localhost",
"contributions": {
"vss.code.web#gitBranchesTreeActions": [
{
"id": "branch-delete",
"title": "Delete...",
"icon": "images/delete.png",
"handler": "main.deleteBranch",
"group": "actions",
"handlerUri": "main.html"
}
]
}
}
Binary file added branch-delete/images/delete-action-screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added branch-delete/images/delete.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added branch-delete/images/fabrikam-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions branch-delete/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Delete Branch</title>
</head>
<body>
<script src="sdk/scripts/VSS.SDK.js"></script>
<script src="scripts/main.js"></script>
<script>
VSS.init({ setupModuleLoader: true });
</script>
</body>
</html>
40 changes: 40 additions & 0 deletions branch-delete/scripts/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
window.main = (function () {
"use strict";

return {
deleteBranch: function (sourceItemContext) {
var url = sourceItemContext.url;
if (url && confirm("Are you sure you want to delete the branch '" + sourceItemContext.friendlyName + "'?")) {

// Parse the repository ID from the URL
// NOTE: This is a temprary workaround. In the near future the sourceItemContext will contain a representation of the repo.
var pre = "git/repositories/";
var repoIdIndex = url.indexOf(pre) + pre.length;
var until = url.indexOf("/", repoIdIndex);
until = until >= 0 ? until : url.length;
var repoId = url.substring(repoIdIndex, until);

// Post the ref update
VSS.ready(function () {
require(["VSS/Service", "VersionControl/Scripts/Generated/TFS.VersionControl.Contracts", "VersionControl/Scripts/Generated/TFS.VersionControl.Git.WebApi"], function (VSS_Service, TFS_VersionControl_Contracts, TFS_Git_WebApi) {
// Get repo name from repo ID (needed to refresh the page)
// NOTE: This is also a temporary workaround
var gitClient = VSS_Service.getCollectionClient(TFS_Git_WebApi.GitHttpClient);
gitClient.getRepository(repoId).then(function (repo) {
gitClient.updateRefs([{
name: sourceItemContext.name,
oldObjectId: sourceItemContext.objectId,
newObjectId: "0000000000000000000000000000000000000000"
}], repoId).then(function () {
var vsoContext = VSS.getWebContext();
// Create URL to branches page (in order to refresh after deleting the branch)
// NOTE: An API to refresh just the view will likely replace this approach for refreshing the branch list.
window.parent.location.href = vsoContext.host.uri + "/" + vsoContext.project.name + "/_git/" + repo.name + "/branches";
});
});
});
});
}
}
};
} ());
Loading

0 comments on commit 583ca6b

Please sign in to comment.