mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2025-02-16 17:30:27 +00:00
github: split up commit and push
This commit is contained in:
parent
c4e03df416
commit
efe0e032fb
@ -365,7 +365,7 @@ if (window.location.host.endsWith('8bitworkshop.com')) {
|
|||||||
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
|
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
|
||||||
<script src="bootstrap/js/bootstrap.min.js"></script>
|
<script src="bootstrap/js/bootstrap.min.js"></script>
|
||||||
<script src="bootstrap/js/bootbox.all.min.js"></script>
|
<script src="bootstrap/js/bootbox.all.min.js"></script>
|
||||||
<link rel="stylesheet" href="bootstrap-tourist/bootstrap-tourist.min.css">
|
<link rel="stylesheet" href="bootstrap-tourist/bootstrap-tourist.css">
|
||||||
<script src="bootstrap-tourist/bootstrap-tourist.js"></script>
|
<script src="bootstrap-tourist/bootstrap-tourist.js"></script>
|
||||||
|
|
||||||
<script src="src/codemirror/codemirror.js"></script>
|
<script src="src/codemirror/codemirror.js"></script>
|
||||||
|
@ -24,6 +24,7 @@ export interface GHSession extends GHRepoMetadata {
|
|||||||
repo : any; // [repo object]
|
repo : any; // [repo object]
|
||||||
tree? : any; // [tree object]
|
tree? : any; // [tree object]
|
||||||
head? : any; // [head ref]
|
head? : any; // [head ref]
|
||||||
|
commit?: any; // after commit()
|
||||||
paths? : string[];
|
paths? : string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,7 +264,7 @@ export class GithubService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
commitPush( ghurl:string, message:string, files:{path:string,data:FileData}[] ) : Promise<GHSession> {
|
commit( ghurl:string, message:string, files:{path:string,data:FileData}[] ) : Promise<GHSession> {
|
||||||
var sess : GHSession;
|
var sess : GHSession;
|
||||||
return this.getGithubHEADTree(ghurl).then( (session) => {
|
return this.getGithubHEADTree(ghurl).then( (session) => {
|
||||||
sess = session;
|
sess = session;
|
||||||
@ -303,10 +304,17 @@ export class GithubService {
|
|||||||
sess.head.object.sha
|
sess.head.object.sha
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
}).then( (commit1) => {
|
||||||
|
return sess.repo.commits(commit1.sha).fetch();
|
||||||
}).then( (commit) => {
|
}).then( (commit) => {
|
||||||
return sess.head.update({
|
sess.commit = commit;
|
||||||
sha: commit.sha
|
return sess;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
push(sess:GHSession) : Promise<GHSession> {
|
||||||
|
return sess.head.update({
|
||||||
|
sha: sess.commit.sha
|
||||||
}).then( (update) => {
|
}).then( (update) => {
|
||||||
return sess;
|
return sess;
|
||||||
});
|
});
|
||||||
|
10
src/ui.ts
10
src/ui.ts
@ -402,7 +402,7 @@ function getGithubService() {
|
|||||||
function getBoundGithubURL() : string {
|
function getBoundGithubURL() : string {
|
||||||
var toks = (repo_id||'').split('/');
|
var toks = (repo_id||'').split('/');
|
||||||
if (toks.length != 2) {
|
if (toks.length != 2) {
|
||||||
alertError("You are not in a GitHub repository. Choose Import or Publish first.");
|
alertError("You are not in a GitHub repository. Choose one from the pulldown, or Import or Publish one.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return 'https://github.com/' + toks[0] + '/' + toks[1];
|
return 'https://github.com/' + toks[0] + '/' + toks[1];
|
||||||
@ -525,7 +525,9 @@ function pushChangesToGithub(message:string) {
|
|||||||
setWaitDialog(true);
|
setWaitDialog(true);
|
||||||
return getGithubService().login().then( () => {
|
return getGithubService().login().then( () => {
|
||||||
setWaitProgress(0.5);
|
setWaitProgress(0.5);
|
||||||
return getGithubService().commitPush(ghurl, message, files);
|
return getGithubService().commit(ghurl, message, files);
|
||||||
|
}).then( (sess) => {
|
||||||
|
return getGithubService().push(sess);
|
||||||
}).then( (sess) => {
|
}).then( (sess) => {
|
||||||
setWaitDialog(false);
|
setWaitDialog(false);
|
||||||
alertInfo("Pushed files to " + ghurl);
|
alertInfo("Pushed files to " + ghurl);
|
||||||
@ -777,7 +779,7 @@ function populateRepos(sel) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function populateFiles(sel:JQuery, category:string, prefix:string, callback:() => void) {
|
function populateFiles(sel:JQuery, category:string, prefix:string, callback:() => void) {
|
||||||
store.keys(function(err, keys : string[]) {
|
store.keys().then( (keys:string[]) => {
|
||||||
var foundSelected = false;
|
var foundSelected = false;
|
||||||
var numFound = 0;
|
var numFound = 0;
|
||||||
if (!keys) keys = [];
|
if (!keys) keys = [];
|
||||||
@ -804,10 +806,10 @@ function populateFiles(sel:JQuery, category:string, prefix:string, callback:() =
|
|||||||
function updateSelector() {
|
function updateSelector() {
|
||||||
var sel = $("#preset_select").empty();
|
var sel = $("#preset_select").empty();
|
||||||
if (!repo_id) {
|
if (!repo_id) {
|
||||||
|
populateRepos(sel);
|
||||||
// normal: populate local and shared files
|
// normal: populate local and shared files
|
||||||
populateFiles(sel, "Local Files", "local/", () => {
|
populateFiles(sel, "Local Files", "local/", () => {
|
||||||
populateFiles(sel, "Shared", "shared/", () => {
|
populateFiles(sel, "Shared", "shared/", () => {
|
||||||
populateRepos(sel);
|
|
||||||
populateExamples(sel);
|
populateExamples(sel);
|
||||||
sel.css('visibility','visible');
|
sel.css('visibility','visible');
|
||||||
});
|
});
|
||||||
|
@ -107,10 +107,13 @@ describe('Store', function() {
|
|||||||
for (var i=0; i<256; i++)
|
for (var i=0; i<256; i++)
|
||||||
binfile[i] = i;
|
binfile[i] = i;
|
||||||
var files = [
|
var files = [
|
||||||
{path:'text.txt', data:'hello world'},
|
{path:'text.txt', data:'hello world ' + Math.random()},
|
||||||
{path:'data.bin', data:binfile}
|
{path:'data.bin', data:binfile}
|
||||||
];
|
];
|
||||||
gh.commitPush('https://github.com/pzpinfo/testrepo3', 'test commit', files).then( (sess) => {
|
gh.commit('https://github.com/pzpinfo/testrepo3', 'test commit', files).then( (sess) => {
|
||||||
|
return gh.push(sess);
|
||||||
|
}).then( (sess) => {
|
||||||
|
console.log(sess.commit);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -122,7 +125,7 @@ describe('Store', function() {
|
|||||||
var files = [
|
var files = [
|
||||||
{path:'text.txt', data:'hello world'}
|
{path:'text.txt', data:'hello world'}
|
||||||
];
|
];
|
||||||
gh.commitPush('https://github.com/brovador/NESnake/tree/master/src', 'test commit', files)
|
gh.commit('https://github.com/brovador/NESnake/tree/master/src', 'test commit', files)
|
||||||
.catch( (e) => {
|
.catch( (e) => {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
assert.equal(e, 'Sorry, right now you can only commit files to the root directory of a repository.');
|
assert.equal(e, 'Sorry, right now you can only commit files to the root directory of a repository.');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user