GitBranch.vala
[gitlive] / GitBranch.vala
1 /**
2 represent a git branch..
3
4 */
5
6 public class GitBranch : Object
7 {
8         public GitRepo repo;
9         
10         public bool active = false;
11         public string lastrev = "";
12         public string name = "";
13         public string remote = "":
14         public string remoterev = "";
15         
16         public GitBranch(GitRepo repo)
17         {
18                 this.repo = repo;
19         }
20
21         public bool parseBranchListItem(str)
22         {
23                 if (!str.length) {
24                         return false;
25                 }
26                 this.active = str[0] == '*';
27                 
28                 var bits = Regex.split_simple ("[ \t]+", str.substring(2).strip());
29                 if (bits[1] == "->") { // it's an alias.. eg. remotes/origin/HEAD -> origin/master..
30                         return false;
31                 }
32                 
33                 this.lastrev = parts[1];
34                 if (parts[0].has_prefix("remotes/")) {
35                         this.remote = parts[0];
36                 } else {
37                         this.name = parts[0];
38                 }
39         
40         
41         }