schacon / asgit

ActionScript Git library and browser implementation

This URL has Read+Write access

asgit / src / Git.mxml
100644 104 lines (86 sloc) 2.863 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" width="800" height="600" initialize="initApp()"
verticalScrollPolicy="off"
horizontalScrollPolicy="off">
 
<mx:Style source="style.css"/>
 
<mx:Script>
<![CDATA[
import mx.core.UIComponent;
import mx.controls.Image;
import mx.collections.ArrayCollection;
import chacon.utils.ByteArrayPack;
import chacon.git.*;
 
// TODO :
// * browse
// * clear icon cache button
// * deal with pack files
// * cache trees and commits in sqlite
//
// * init
// * clone
// * add
// * commit
 
private var git:AsGit;
private var gitDir:String;
 
public function initApp():void {
changeGitPath('/Users/schacon/projects/simplegit');
}
 
public function changeGitPath(path:String):void {
var dir:String = path;
git = new AsGit(dir);
gitDir = dir;
}
 
public function initLogs():void {
switchDir.label = gitDir;
//tree.directory = new File(dir);
fillLog();
}
 
public function fillLog():void {
var logArr:Array = git.log();
log.dataProvider = new ArrayCollection(logArr.reverse());
}
 
public function switchDirectories():void {
viewstack.selectedIndex = 1;
}
 
public function trySwitch():void {
var path:String = tree.selectedPath;
trace(path);
var selectPath:File = new File(path);
if(selectPath.isDirectory) {
if(selectPath.resolvePath('.git').exists) {
changeGitPath(path);
initLogs();
viewstack.selectedIndex = 0;
}
}
}
 
public function showLog():void {
output.text = log.selectedItem.raw;
output.text += git.readObject(log.selectedItem.parents[0]).raw;
}
 
]]>
</mx:Script>
    
<mx:ViewStack x="0" y="0" id="viewstack" width="100%" height="100%">
 
<mx:VBox height="100%" width="100%" initialize="initLogs()"
paddingLeft="10" paddingRight="10" paddingTop="10" paddingBottom="10">
<mx:HBox width="100%" height="30">
<mx:Image source="/img/git-logo.png"/>
<mx:Button id="switchDir" click="switchDirectories()" label="Choose Directory"/>
<mx:Spacer width="100%"/>
<mx:Text text="Branch:"/>
<mx:ComboBox></mx:ComboBox>
</mx:HBox>
<mx:HBox width="100%" height="100%">
<mx:List id="log" width="250" height="100%" click="showLog()" itemRenderer="CommitRenderer"/>
<mx:Text id="output" text="output" width="100%" height="100%"/>
</mx:HBox>
</mx:VBox>
 
<mx:TitleWindow id="dirChooser" width="100%" height="100%">
<mx:VBox width="100%" height="100%">
<mx:FileSystemTree id="tree" width="100%" height="100%"/>
<mx:Button id="chooseDir" click="trySwitch()" label="Choose Directory"/>
</mx:VBox>
</mx:TitleWindow>
 
</mx:ViewStack>
 
</mx:WindowedApplication>