2011-12-14 12 views
21

C'è qualche libreria javascript che permette di leggere e impegnano file su un server Subversion?Javascript SVN involucro

Il server potrebbe utilizzare il protocollo svn:// o il protocollo http:// (dav_svn). Se uno è più conveniente, va bene, anche se una libreria in grado di gestire entrambi i tipi è meglio.

Vorrei evitare di dover creare una copia di lavoro locale del repository (è anche possibile eseguire il checkout di un repository in Javascript: p ...).

Chiunque vede una soluzione? Mi sono guardato intorno ma non ho trovato nulla.

+0

Quale tipo di codice JavaScript si desidera utilizzare? JavaScript in un browser oder ad es. node.js? – TimWolla

+0

Javascript in un browser. Mi piacerebbe fare una sorta di visualizzazione rapida/modifica per un repository SVN (e senza fare affidamento su un server PHP/Java per fare il lavoro). –

+0

In realtà sto avendo la stessa domanda, ma volevo fare DIFF in questo modo - fornendo un modo per mostrare le modifiche per una determinata revisione senza passare attraverso i comandi basati sul server.Matthieu: l'hai finalmente fatto funzionare? Sei in grado di fare anche DIFF? –

risposta

0

È possibile scrivere i propri comandi Svn in una serie di file di comandi e quindi eseguirli all'interno del proprio script.

/* Create WSH Shell */ 
oShell = WScript.CreateObject("WScript.Shell"); 

/* Launch svn.exe with other orguments */ 
oShell.Run("svn.exe svn://192.168.40.41 Param1 param2"); 

/* Let the user know that we are done   */ 
WScript.Echo("Done"); 

Ma come sapete, questo non è sicuro.

+0

Oltre a non essere sicuro, ha anche due inconvenienti: 1) avrete problemi a farlo girare su tutti i sistemi operativi (dovete adattare la linea di comando per ciascuno dei sistemi operativi supportati, che è un dolore), E 2) richiede a tutti gli utenti di avere un client SVN a riga di comando installato e disponibile nel PATH, il che non sempre sarà il caso - non guarderò sempre questa pagina web dalla tua macchina di sviluppo, immagino. –

3

Il https://github.com/sara-nl/js-webdav-client non ha funzionato per me

Ho usato jQuery per leggere un file XML:

var URL = window.location.href; 
var baseURL = URL.substring(0, URL.lastIndexOf('/')); 
$.ajax({ 
    type: "OPTIONS", 
    url: baseURL, 
    contentType: "text/xml", //for other files look up the api link below 
    headers: {Depth: "0"}, 
    data: '<?xml version="1.0" encoding="utf-8" ?><D:options xmlns:D="DAV:"><D:activity-collection-set></D:activity-collection-set></D:options>', 
    success: function(data1, status, jqxhr){ 
     latestRev = jqxhr.getResponseHeader('SVN-Youngest-Rev'); 
     $.ajax({ 
      type: "PROPFIND", 
      url: baseURL + '/!svn/rvr/' + latestRev, 
      contentType: "text/xml", 
      headers: {Depth: "0"}, 
      data: '<?xml version="1.0" encoding="utf-8" ?><propfind xmlns="DAV:"><prop><resourcetype xmlns="DAV:"/></prop></propfind>', 
      success: function(data2, status, jqxhr){ 
       $.ajax({ 
        type: "OPTIONS", 
        url: baseURL, 
        contentType: "text/xml", 
        headers: {Depth: "0"}, 
        data: '<?xml version="1.0" encoding="utf-8" ?><D:options xmlns:D="DAV:"><D:activity-collection-set></D:activity-collection-set></D:options>', 
        success: function(data3, status, jqxhr){ 
         $.ajax({ 
          type: "REPORT", 
          url: baseURL + "/!svn/me", 
          contentType: "text/xml", 
          data: '<S:update-report xmlns:S="svn:"><S:include-props>yes</S:include-props><S:src-path>/svn/check</S:src-path><S:target-revision>' + latestRev + '</S:target-revision><S:depth>unknown</S:depth><S:entry depth="infinity" rev="' + latestRev + '"></S:entry></S:update-report>', 
          success: function(data4,status,jqxhr){ 
           svnSpecs = data4; 
           $.ajax({ 
            type: "GET", 
            url: '/svn/check/!svn/rvr/' + latestRev + '/KickOff.xml', 
            converters: {"text xml": function(obj) { 
             hashBase = calcMD5(obj); 
             return obj; 
            }}, 
            cache: false, 
            async: false, 
            success: function(data5, status, jqxhr){ 
             hashdata5 = calcMD5(data5); 
             xmlString = $($.parseXML(data5)); 
             drawTable(xmlString); 
            }, 
           }); 
          }, 
         }); 
        }, 
       }); 
      }, 
     }); 
    }, 
}); 

Se si desidera importare altri file di xml cercarlo qui: http://api.jquery.com/jQuery.ajax/

In data4/svnSpecs puoi trovare ogni parola chiave che hai usato all'interno del tuo xml - fai lo stesso come con xmlString

Con a = xmlString.find("Member"); si ottiene un array con tutti i membri oggetto denominato del xml se lo fai a[0].textContent = "Harry"; si imposta il contenuto del primo oggetto all'interno del tuo xmlString a Harry -> si può solo fare un drawTable() seguito per aggiornare il vostro tavolo

EDIT: All'interno del drawTable() methode si hanno a che fare il a.find(""), var list = []; e list.push("html text for a table") ed un $("#membertable").html(list); di scrivere everthing nella tabella esistente "membertable"

il hashBase è importante per commettere. Non ho finito con il commit ma quasi. codice attuale e processo è qui: how to do SVN http-request checkin/commit within html

+0

Si prega di notare che questo codice è compatibile con SVN versione 1.7+ – Inferpse

Problemi correlati