feat(git): Teilen von Git-Brews über Server-Snapshot (#9) (#25)
CI / App (npm ci + Build, ESLint, Stylelint, Jest) (push) Successful in 2m12s
CI / Storage (mongo) (push) Successful in 1m41s
CI / Storage (postgres) (push) Successful in 1m13s
Image / Image bauen und pushen (push) Successful in 5m18s

Co-authored-by: Dev (Paperclip) <dev-bot@noreply.git.morlana.online>
This commit was merged in pull request #25.
This commit is contained in:
dev-bot Bot authored and Gitea committed 2026-11-26 01:01:31 +00:00
1 parent adaa10a4dc
commit 3a77763641
8 files changed
+94 -4

No files matched your search

+4 -3
View File
@@ -27,7 +27,7 @@ export const publicConnection = (conn)=>({
lastVerifiedAt : conn.lastVerifiedAt
});
const publicStatus = (link, conn, { isConnectionOwner = false } = {})=>link ? {
const publicStatus = (link, conn, { isConnectionOwner = false, brew } = {})=>link ? {
linked : true,
connectionId : conn?.id,
connectionLabel : conn?.label,
@@ -37,6 +37,7 @@ const publicStatus = (link, conn, { isConnectionOwner = false } = {})=>link ? {
lastCommitSha : link.lastCommitSha,
lastSyncedAt : link.lastSyncedAt,
lastError : link.lastError,
snapshotAt : brew?.updatedAt ?? null, // Stand, den Share-Links ausliefern (ADR 0003 §6)
isConnectionOwner
} : { linked: false };
@@ -321,7 +322,7 @@ export const createGitService = ({ cfg, getStorage, api, splitTextStyleAndMetada
return svc.locks.withKey(brew.id, async ()=>{
const { commit, blob } = await svc.commitContent(conn, { branch, filePath, content: brew.text, expectedBlob: null, author });
const link = await storage().brewGitLinks.upsert({ brewId: brew.id, connectionId: conn.id, branch, path: filePath, lastCommitSha: commit, lastBlobSha: blob, lastSyncedAt: new Date(), lastError: null });
return publicStatus(link, conn, { isConnectionOwner: true });
return publicStatus(link, conn, { isConnectionOwner: true, brew });
});
},
@@ -339,7 +340,7 @@ export const createGitService = ({ cfg, getStorage, api, splitTextStyleAndMetada
const link = await storage().brewGitLinks.findByBrewId(brew.id);
if(!link) return { linked: false };
const conn = await storage().gitConnections.findById(link.connectionId);
return publicStatus(link, conn, { isConnectionOwner: !!account.uid && conn?.ownerUserId === account.uid });
return publicStatus(link, conn, { isConnectionOwner: !!account.uid && conn?.ownerUserId === account.uid, brew });
},
async pull(account, editId) {
+2 -1
View File
@@ -33,7 +33,8 @@ const HomebrewSchema = mongoose.Schema({
}, { versionKey: false });
HomebrewSchema.pre('save', function() {
if(this.text !== undefined) {
// Nur bei neuem/geändertem Text: der Default '' beim Laden darf textBin nicht überschreiben.
if(this.text !== undefined && (this.isNew || this.isModified('text'))) {
this.textBin = zlib.deflateRawSync(this.text);
this.text = undefined;
}
+10
View File
@@ -164,6 +164,16 @@ export const runBrewRepositoryContract = (createBrews)=>{
expect(new Date(r2.lastViewed).getTime()).toBeGreaterThan(before.getTime());
expect((await brews.findByShareId(b.shareId)).views).toBe(2);
});
test('Text bleibt nach incrementViews und update ohne text erhalten', async ()=>{
const b = await brews.create(sample());
await brews.incrementViews(b.shareId);
expect((await brews.findByShareId(b.shareId)).text).toBe(sample().text);
await brews.update({ id: b.id, title: 'Neu' });
expect((await brews.findByShareId(b.shareId)).text).toBe(sample().text);
await brews.update({ id: b.id, text: '' });
expect((await brews.findByShareId(b.shareId)).text).toBe('');
});
});
describe('Vault-Suche', ()=>{
+1
View File
@@ -99,6 +99,7 @@ export const createBrewRepository = ()=>{
const doc = await HomebrewModel.findOne({ _id: brew.id });
if(!doc) return null;
const merged = _.assign(doc, withoutId(brew));
if(brew.text !== undefined) merged.markModified('text'); // auch bei text === '' (Default) speichern
const saved = await merged.save();
const plain = toPlain(saved);
if(brew.text !== undefined) plain.text = brew.text;