TrackGit
Init.cpp
Go to the documentation of this file.
1 
8 #include "Init.h"
9 #include "../Utils.h"
10 
11 #include <InterfaceKit.h>
12 
13 #include <git2.h>
14 
15 
20 Init::Init(BString dirPath)
21  :
22  GitCommand()
23 {
24  fDirPath = dirPath;
25 }
26 
27 
33 int
34 Init::InitRepo(BString dirPath)
35 {
36  git_repository* repo = NULL;
37  return git_repository_init(&repo, dirPath.String(), 0);
38 }
39 
40 
44 void
46 {
47  if (InitRepo(fDirPath) < 0) {
48  const git_error* err = giterr_last();
49  printf("Error %d : %s\n", err->klass, err->message);
50 
51  BString buffer("Error : %s");
52  buffer.ReplaceFirst("%s", err->message);
53  BAlert* alert = new BAlert("", buffer.String(), "Cancel",
54  0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
55  alert->Go();
56  } else {
57  BString buffer("Repository initialted sucessfully.");
58  BAlert* alert = new BAlert("", buffer.String(), "OK",
59  0, 0, B_WIDTH_AS_USUAL);
60  alert->Go();
61  }
62 
63  BMessenger messenger(APP_SIGN);
64  messenger.SendMessage(new BMessage(kQuitWindow));
65 }
#define APP_SIGN
The Application signature.
Definition: Utils.h:45
virtual void Execute()
Init command excution.
Definition: Init.cpp:45
Header file of Init command.
GitCommand Class.
Definition: GitCommand.h:20
Init(BString)
Init command constructor.
Definition: Init.cpp:20
BString fDirPath
The current directory where Init option is selected.
Definition: Init.h:23
static int InitRepo(BString)
Initializes empty repo in given directory.
Definition: Init.cpp:34