1- import { Change , InsertCommit , Socket , wrap } from "../../deps/socket.ts" ;
1+ import { Change , Socket , wrap } from "../../deps/socket.ts" ;
22import { HeadData } from "./pull.ts" ;
3- import { createNewLineId , getProjectId , getUserId } from "./id.ts" ;
4- import { CodeFile } from "./updateCodeFile.ts" ;
3+ import { getProjectId , getUserId } from "./id.ts" ;
54import { pushWithRetry } from "./_fetch.ts" ;
5+ import { TinyCodeBlock } from "./getCodeBlocks.ts" ;
66
77/** コミットを送信する一連の処理 */
88export async function applyCommit (
@@ -28,30 +28,10 @@ export async function applyCommit(
2828 } ) ;
2929}
3030
31- /** 新規コードブロックのコミットを作成する */
32- export function * makeCommitsNewCodeBlock (
33- code : CodeFile ,
34- insertLineId : string ,
35- { userId } : { userId : string } ,
36- ) : Generator < InsertCommit , void , unknown > {
37- const codeName = code . filename + ( code . lang ? `(${ code . lang } )` : "" ) ;
38- const codeBody = Array . isArray ( code . content )
39- ? code . content
40- : code . content . split ( "\n" ) ;
41- yield {
42- _insert : insertLineId ,
43- lines : {
44- id : createNewLineId ( userId ) ,
45- text : `code:${ codeName } ` ,
46- } ,
47- } ;
48- for ( const bodyLine of codeBody ) {
49- yield {
50- _insert : insertLineId ,
51- lines : {
52- id : createNewLineId ( userId ) ,
53- text : " " + bodyLine ,
54- } ,
55- } ;
56- }
31+ /** コードブロック本文のインデント数を計算する */
32+ export function countBodyIndent (
33+ codeBlock : Pick < TinyCodeBlock , "titleLine" > ,
34+ ) : number {
35+ return codeBlock . titleLine . text . length -
36+ codeBlock . titleLine . text . trimStart ( ) . length + 1 ;
5737}
0 commit comments