/// <summary> /// Construct a new <seealso cref="PersonIdent"/> with current time. /// </summary> /// <param name="name"> </param> /// <param name="emailAddress"></param> public PersonIdent(string name, string emailAddress) { Name = name; EmailAddress = emailAddress; When = SystemReader.getInstance().getCurrentTime(); tzOffset = SystemReader.getInstance().getTimezone(When); }
public RepositoryConfig(Repository repo) : this(SystemReader.getInstance().openUserConfig(), new FileInfo(Path.Combine(repo.Directory.FullName, "config"))) { if (repo == null) { throw new System.ArgumentNullException("repo"); } }
private readonly int tzOffset; // offset in minutes to UTC /// <summary> /// Creates new PersonIdent from config info in repository, with current time. /// This new PersonIdent gets the info from the default committer as available /// from the configuration. /// </summary> /// <param name="repo"></param> public PersonIdent(Repository repo) { RepositoryConfig config = repo.Config; Name = config.getCommitterName(); EmailAddress = config.getCommitterEmail(); When = SystemReader.getInstance().getCurrentTime(); tzOffset = SystemReader.getInstance().getTimezone(When); }
static private List <RepositoryListener> allListeners = new List <RepositoryListener>(); //TODO: make thread safe /** * Construct a representation of a Git repository. * * @param d * GIT_DIR (the location of the repository metadata). * @throws IOException * the repository appears to already exist but cannot be * accessed. */ public Repository(DirectoryInfo gitDirectory) { Directory = gitDirectory; _refDb = new RefDatabase(this); _objectDatabase = new ObjectDirectory(new DirectoryInfo(FS.resolve(gitDirectory, "objects").FullName)); var userConfig = SystemReader.getInstance().openUserConfig(); try { userConfig.load(); } catch (ConfigInvalidException e1) { Dispose(); throw new IOException("User config file " + userConfig.getFile().FullName + " invalid: " + e1, e1); } Config = new RepositoryConfig(userConfig, (FileInfo)FS.resolve(gitDirectory, "config")); WorkingDirectory = gitDirectory.Parent; if (_objectDatabase.exists()) { try { Config.load(); } catch (ConfigInvalidException e1) { Dispose(); throw new IOException("Unknown repository format", e1); } string repositoryFormatVersion = Config.getString("core", null, "repositoryFormatVersion"); if (!"0".Equals(repositoryFormatVersion)) { Dispose(); throw new IOException("Unknown repository format \"" + repositoryFormatVersion + "\"; expected \"0\"."); } } }
/** * @param newReader * the new instance to use when accessing properties. */ public static void setInstance(SystemReader newReader) { _instance = newReader; }
private PackList ScanPacksImpl(PackList old) { Dictionary <string, PackFile> forReuse = ReuseMap(old); long lastRead = SystemReader.getInstance().getCurrentTime(); long lastModified = _packDirectory.lastModified(); HashSet <String> names = listPackDirectory(); var list = new List <PackFile>(names.Count >> 2); bool foundNew = false; foreach (string indexName in names) { // Must match "pack-[0-9a-f]{40}.idx" to be an index. // if (indexName.Length != 49 || !indexName.EndsWith(".idx")) { continue; } string @base = indexName.Slice(0, indexName.Length - 4); string packName = IndexPack.GetPackFileName(@base); if (!names.Contains(packName)) { // Sometimes C Git's HTTP fetch transport leaves a // .idx file behind and does not download the .pack. // We have to skip over such useless indexes. // continue; } PackFile oldPack; forReuse.TryGetValue(packName, out oldPack); forReuse.Remove(packName); if (oldPack != null) { list.Add(oldPack); continue; } var packFile = new FileInfo(_packDirectory.FullName + "/" + packName); var idxFile = new FileInfo(_packDirectory + "/" + indexName); list.Add(new PackFile(idxFile, packFile)); foundNew = true; } // If we did not discover any new files, the modification time was not // changed, and we did not remove any files, then the set of files is // the same as the set we were given. Instead of building a new object // return the same collection. // if (!foundNew && lastModified == old.lastModified && forReuse.isEmpty()) { return(old.updateLastRead(lastRead)); } foreach (PackFile p in forReuse.Values) { p.Dispose(); } if (list.Count == 0) { return(new PackList(lastRead, lastModified, NoPacks.packs)); } PackFile[] r = list.ToArray(); Array.Sort(r, PackFile.PackFileSortComparison); return(new PackList(lastRead, lastModified, r)); }
private SystemReader system() { return(SystemReader.getInstance()); }
public RepositoryConfig(Repository repo) : this(SystemReader.getInstance().openUserConfig(), new FileInfo(Path.Combine(repo.Directory.FullName, "config"))) { }