Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/FolderManager/FileView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public class Scratch.FolderManager.FileView : Granite.Widgets.SourceList, Code.P
foreach (var item in root.children) {
if (item is ProjectFolderItem) {
var folder = (ProjectFolderItem)item;
if (folder.is_git_repo && folder.contains_file (file)) {
if (folder.contains_file (file)) {
return folder;
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/FolderManager/ProjectFolderItem.vala
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,11 @@ namespace Scratch.FolderManager {
return menu;
}

public void update_item_status (FolderItem? start_folder) requires (monitored_repo != null) {
public void update_item_status (FolderItem? start_folder) {
if (monitored_repo == null) {
debug ("Ignore non-git folders");
return;
}
bool is_new = false;
string start_path = start_folder != null ? start_folder.path : "";
visible_item_list.@foreach ((visible_item) => {
Expand Down
28 changes: 19 additions & 9 deletions src/Services/GitManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,30 @@ namespace Scratch.Services {

public MonitoredRepository? add_project (FolderManager.ProjectFolderItem root_folder) {
var root_path = root_folder.file.file.get_path ();
MonitoredRepository? monitored_repo = null;
try {
var git_repo = Ggit.Repository.open (root_folder.file.file);
if (project_gitrepo_map.has_key (root_path)) {
return project_gitrepo_map.@get (root_path);
}
if (!project_gitrepo_map.has_key (root_path)) {

project_liststore.insert_sorted (root_folder, (CompareDataFunc<GLib.Object>) project_sort_func);
var monitored_repo = new MonitoredRepository (git_repo);
project_gitrepo_map.@set (root_path, monitored_repo);
return project_gitrepo_map.@get (root_path);
monitored_repo = new MonitoredRepository (git_repo);
project_gitrepo_map.@set (root_path, monitored_repo);
}
} catch (Error e) {
debug ("Error opening git repo for %s, means this probably isn't one: %s", root_path, e.message);
return null;
debug (
"Error opening git repo for %s, means this probably isn't one: %s",
root_path,
e.message
);
} finally {
project_liststore.insert_sorted (
root_folder,
(CompareDataFunc<GLib.Object>) project_sort_func
);
}

//Ensure active_project_path always set
active_project_path = root_path;
return project_gitrepo_map.@get (root_path);
}

[CCode (instance_pos = -1)]
Expand Down