forked from microsoft/vsts-extension-samples
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd4d78b
commit 583ca6b
Showing
138 changed files
with
27,651 additions
and
0 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
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" | ||
} | ||
] | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,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> |
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,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"; | ||
}); | ||
}); | ||
}); | ||
}); | ||
} | ||
} | ||
}; | ||
} ()); |
Oops, something went wrong.