MCPcopy
hub / github.com/leonhartX/gas-github / commitFiles

Method commitFiles

src/scm/gitlab.js:34–79  ·  view source on GitHub ↗
(repo, branch, parent, newFiles, changedFiles, deleteFiles, comment)

Source from the content-addressed store, hash-verified

32 }
33
34 commitFiles(repo, branch, parent, newFiles, changedFiles, deleteFiles, comment) {
35 return new Promise((resolve, reject) => {
36 const data = {
37 branch: branch,
38 commit_message: comment,
39 actions: []
40 };
41 if (newFiles && newFiles.length > 0) {
42 data.actions = data.actions.concat(newFiles.map((file) => {
43 return {
44 action: 'create',
45 file_path: file.name,
46 content: file.content
47 }
48 }));
49 }
50 if (changedFiles && changedFiles.length > 0) {
51 data.actions = data.actions.concat(changedFiles.map((file) => {
52 return {
53 action: 'update',
54 file_path: file.name,
55 content: file.content
56 }
57 }));
58 }
59 if (deleteFiles && deleteFiles.length > 0) {
60 data.actions = data.actions.concat(deleteFiles.map((file) => {
61 return {
62 action: 'delete',
63 file_path: file
64 }
65 }));
66 }
67 $.ajax({
68 url: `${this.baseUrl}/projects/${getRepo().id}/repository/commits`,
69 headers: this.tokenHeader,
70 contentType: 'application/json',
71 method: 'POST',
72 crossDomain: true,
73 traditional: true,
74 data: JSON.stringify(data)
75 })
76 .then(resolve)
77 .fail(reject);
78 });
79 }
80
81 push(code) {
82 const changed = $('.diff-file:checked').toArray().map(elem => elem.value);

Callers 2

pushMethod · 0.95
createRepoMethod · 0.95

Calls 1

getRepoFunction · 0.85

Tested by

no test coverage detected