use of org.eclipse.jgit.lib.StoredConfig in project gitblit by gitblit.
the class GitblitAuthority method setSizeAndPosition.
private void setSizeAndPosition() {
String sz = null;
String pos = null;
try {
StoredConfig config = getConfig();
sz = config.getString("ui", null, "size");
pos = config.getString("ui", null, "position");
defaultDuration = config.getInt("new", "duration", 365);
} catch (Throwable t) {
t.printStackTrace();
}
// try to restore saved window size
if (StringUtils.isEmpty(sz)) {
setSize(900, 600);
} else {
String[] chunks = sz.split("x");
int width = Integer.parseInt(chunks[0]);
int height = Integer.parseInt(chunks[1]);
setSize(width, height);
}
// try to restore saved window position
if (StringUtils.isEmpty(pos)) {
setLocationRelativeTo(null);
} else {
String[] chunks = pos.split(",");
int x = Integer.parseInt(chunks[0]);
int y = Integer.parseInt(chunks[1]);
setLocation(x, y);
}
}
use of org.eclipse.jgit.lib.StoredConfig in project gitblit by gitblit.
the class JGitUtils method createRepository.
/**
* Creates a bare, shared repository.
*
* @param repositoriesFolder
* @param name
* @param shared
* the setting for the --shared option of "git init".
* @return Repository
*/
public static Repository createRepository(File repositoriesFolder, String name, String shared) {
try {
Repository repo = null;
try {
Git git = Git.init().setDirectory(new File(repositoriesFolder, name)).setBare(true).call();
repo = git.getRepository();
} catch (GitAPIException e) {
throw new RuntimeException(e);
}
GitConfigSharedRepository sharedRepository = new GitConfigSharedRepository(shared);
if (sharedRepository.isShared()) {
StoredConfig config = repo.getConfig();
config.setString("core", null, "sharedRepository", sharedRepository.getValue());
config.setBoolean("receive", null, "denyNonFastforwards", true);
config.save();
if (!JnaUtils.isWindows()) {
Iterator<File> iter = org.apache.commons.io.FileUtils.iterateFilesAndDirs(repo.getDirectory(), TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
// Adjust permissions on file/directory
while (iter.hasNext()) {
adjustSharedPerm(iter.next(), sharedRepository);
}
}
}
return repo;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of org.eclipse.jgit.lib.StoredConfig in project gitblit by gitblit.
the class ITicketService method deleteLabel.
/**
* Deletes a label.
*
* @param repository
* @param label
* @param createdBy
* @return true if the delete was successful
* @since 1.4.0
*/
public synchronized boolean deleteLabel(RepositoryModel repository, String label, String createdBy) {
if (StringUtils.isEmpty(label)) {
throw new IllegalArgumentException("label can not be empty!");
}
Repository db = null;
try {
db = repositoryManager.getRepository(repository.name);
StoredConfig config = db.getConfig();
config.unsetSection(LABEL, label);
config.save();
return true;
} catch (IOException e) {
log.error("failed to delete label " + label + " in " + repository, e);
} finally {
if (db != null) {
db.close();
}
}
return false;
}
use of org.eclipse.jgit.lib.StoredConfig in project gitblit by gitblit.
the class ITicketService method deleteMilestone.
/**
* Deletes a milestone.
*
* @param repository
* @param milestone
* @param createdBy
* @param notifyOpenTickets
* @return true if successful
* @since 1.6.0
*/
public synchronized boolean deleteMilestone(RepositoryModel repository, String milestone, String createdBy, boolean notifyOpenTickets) {
if (StringUtils.isEmpty(milestone)) {
throw new IllegalArgumentException("milestone can not be empty!");
}
Repository db = null;
try {
TicketMilestone tm = getMilestone(repository, milestone);
if (tm == null) {
return false;
}
db = repositoryManager.getRepository(repository.name);
StoredConfig config = db.getConfig();
config.unsetSection(MILESTONE, milestone);
config.save();
milestonesCache.remove(repository.name);
TicketNotifier notifier = createNotifier();
for (QueryResult qr : tm.tickets) {
Change change = new Change(createdBy);
change.setField(Field.milestone, "");
TicketModel ticket = updateTicket(repository, qr.number, change);
if (notifyOpenTickets && ticket.isOpen()) {
notifier.queueMailing(ticket);
}
}
if (notifyOpenTickets) {
notifier.sendAll();
}
return true;
} catch (IOException e) {
log.error("failed to delete milestone " + milestone + " in " + repository, e);
} finally {
if (db != null) {
db.close();
}
}
return false;
}
use of org.eclipse.jgit.lib.StoredConfig in project gitblit by gitblit.
the class ITicketService method updateLabel.
/**
* Updates a label.
*
* @param repository
* @param label
* @param createdBy
* @return true if the update was successful
* @since 1.4.0
*/
public synchronized boolean updateLabel(RepositoryModel repository, TicketLabel label, String createdBy) {
Repository db = null;
try {
db = repositoryManager.getRepository(repository.name);
StoredConfig config = db.getConfig();
config.setString(LABEL, label.name, COLOR, label.color);
config.save();
return true;
} catch (IOException e) {
log.error("failed to update label " + label + " in " + repository, e);
} finally {
if (db != null) {
db.close();
}
}
return false;
}
Aggregations