Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Enable to pass an object to createBlob#464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
dudaerich wants to merge1 commit intogithub-tools:master
base:master
Choose a base branch
Loading
fromdudaerich:issue-463
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletionslib/Repository.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -245,7 +245,7 @@ class Repository extends Requestable {
/**
* Create a blob
* @see https://developer.github.com/v3/git/blobs/#create-a-blob
* @param {(string|Buffer|Blob)} content - the content to add to the repository
* @param {(string|Buffer|Blob|Object)} content - the content to add to the repository
* @param {Requestable.callback} cb - will receive the details of the created blob
* @return {Promise} - the promise for the http request
*/
Expand All@@ -258,7 +258,7 @@ class Repository extends Requestable {

/**
* Get the object that represents the provided content
* @param {string|Buffer|Blob} content - the content to send to the server
* @param {string|Buffer|Blob|Object} content - the content to send to the server
* @return {Object} the representation of `content` for the GitHub API
*/
_getContentObject(content) {
Expand All@@ -283,9 +283,18 @@ class Repository extends Requestable {
encoding: 'base64',
};

} else if (typeof content === 'object') {
log('content is an object');

if (typeof content.content !== 'string') {
throw new Error('The object must contain content item of type string.');
}

return content;

} else { // eslint-disable-line
log(`Not sure what this content is: ${typeof content}, ${JSON.stringify(content)}`);
throw new Error('Unknown content passed to postBlob. Must be string or Buffer (node) or Blob (web)');
throw new Error('Unknown content passed to postBlob. Must be string or Buffer (node) or Blob (web) or Object');
}
}

Expand Down
10 changes: 10 additions & 0 deletionstest/repository.spec.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -578,6 +578,16 @@ describe('Repository', function() {
remoteRepo.createBlob(imageBlob,assertSuccessful(done));
});

it('should read the same unicode string blob as it was written',function(done){
letcontent='The temperature is 25°C'
remoteRepo.createBlob({content:content,encoding:'utf-8'},assertSuccessful(done,function(_,resp){
remoteRepo.getBlob(resp.sha,assertSuccessful(done,function(_,returnedContent){
expect(returnedContent).to.be(content);
done();
}));
}));
});

it('should star the repo',function(done){
remoteRepo.star(assertSuccessful(done,function(){
remoteRepo.isStarred(assertSuccessful(done));
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp