Commit bd70670f authored by Ivanq's avatar Ivanq

Merge branch 'primport'

parents 6ab42483 7fafa88e
......@@ -567,6 +567,22 @@ class Repository {
);
});
}
importPullRequest(pullRequest) {
let other = new Repository(pullRequest.fork_address, this.zeroPage);
let ref;
return other.addMerger()
.then(() => {
return other.git.getBranchCommit(pullRequest.fork_branch);
})
.then(r => {
ref = r;
return this.git.importObjectWithDependencies(other.git, ref);
})
.then(() => {
return this.git.setRef("refs/heads/pr-" + pullRequest.id + "-" + pullRequest.json_id, ref);
});
}
// Maintainers
getUsers() {
......
......@@ -80,6 +80,7 @@
<a class="button button-blue comment-submit" id="comment_submit">Comment</a>
<a class="button comment-submit-close" id="comment_submit_close">Comment</a>
<a class="button comment-submit-close" id="comment_import">Import</a>
</div>
<template id="edit_icon_tmpl">
......
......@@ -121,5 +121,24 @@ repo.addMerger()
contentNode.disabled = false;
});
};
let commentImport = document.getElementById("comment_import");
commentImport.style.display = "inline-block";
commentImport.title = "Import branch " + pullRequest.fork_address + "/" + pullRequest.fork_branch + " as " + address + "/pr-" + id + "-" + jsonId;
commentImport.onclick = () => {
if(commentImport.classList.contains("button-disabled")) {
return;
}
commentImport.classList.add("button-disabled");
repo.importPullRequest(pullRequest)
.then(() => {
zeroPage.alert("Branch pr-" + id + "-" + jsonId + " was imported to your repository. Run git fetch to download and merge it.");
commentImport.classList.remove("button-disabled");
}, e => {
zeroPage.error(e);
commentImport.classList.remove("button-disabled");
});
};
}
});
\ No newline at end of file
......@@ -146,7 +146,7 @@
To let people speak about some project, Git Center added support for issues. You can see them on <b>Issues</b> tab, create them by pressing <a class="button button-blue">New issue</a> and then comment it. Other people can post comments then.
</p>
<p>
You can also have pull requests. If people fork your repository and then create a pull request with a reference to that fork you can accept these requests and manually merge it. Git Center uses ZeroNet functions and has to implement <code>git</code> using JavaScript, so merging would be really difficult.
You can also have pull requests. If people fork your repository and then create a pull request with a reference to that fork you can accept these requests and merge them. To do that, press <a class="button">Import</a>, then run <code>git fetch</code> on your local repository, merge branch <code>pr-...-...</code> manually and then <code>git push</code>.
</p>
</div>
</body>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment