TFS Rest API check-in to Version Control

瘦欲@ 提交于 2019-12-02 06:44:52

A sample code for your reference with createChangeset() method:

/// <reference path="typings/index.d.ts" />

import * as vm from 'vso-node-api/WebApi';
import * as vss from 'vso-node-api/interfaces/Common/VSSInterfaces';
import * as tfv from 'vso-node-api/TFVCApi'
import * as tfi from 'vso-node-api/interfaces/TFVCInterfaces';

var collectionUrl = "https://xxxxxx.visualstudio.com";
let token: string = "xxxxxx";
let creds = vm.getPersonalAccessTokenHandler(token);
var connection = new vm.WebApi(collectionUrl, creds); 
let vstsTF: tfv.ITfvcApi = connection.getTfvcApi();

async function createCS(){
    var csdata = {
            comment: "test",
            changes: [
                {
                    changeType: tfi.VersionControlChangeType.Add,
                    item: {
                        path: "$/TFVCBranches/Test/3.txt",
                        contentMetadata: { encoding: 65001 },
                    },
                    newContent: {
                        content: "Placeholder file for new folder",
                        contentType: tfi.ItemContentType.RawText
                    }
                }]
        };
    (<any>vstsTF).createChangeset(csdata);

}

createCS();

There isn’t the Rest API (public/released by microsoft) that can check-in changes like edit code and check-in changes (save) on web access.

I submitted a user voice here, you can vote and track it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!