Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit eded777

Browse files
committed
Merge master into fixes/progress
2 parents 97c9571 + b89e924 commit eded777

27 files changed

+1017
-210
lines changed

docs/contributing/how-to-build.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,3 @@ The `GitHub.Unity.sln` solution includes several projects:
6868
- GitHub.Logging: A logging helper library
6969
- GitHub.Api: The core of the extension. This project is C#6 and includes async/await threading and other features that Unity cannot currently compile.
7070
- GitHub.Unity: Unity-specific code. This project is compilable by Unity
71-
72-
## Other solutions
73-
74-
Octokit is normally included as a prebuilt DLL (in the `lib` directory), but when updating Octokit or debugging issues with the 3.5 backport, it can sometimes be handy to reference the project directly. The `GitHub.Unity.OctokitDebugging.sln` solution is a helper solution that includes Octokit and dotnet-httpclient35 as referenced projects instead of prebuilt dlls.
75-
76-
This solution requires a clone of [https://github.com/github-for-unity/octokit.net](https://github.com/github-for-unity/octokit.net) and [https://github.com/github-for-unity/dotnet-httpclient35](https://github.com/github-for-unity/dotnet-httpclient35) to exist next to your GitHub for Unity checkout.

docs/readme.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ Details about how the team is organizing and shipping GitHub for Unity:
2828
- **[Roadmap](process/roadmap.md)** - how we plan for the future
2929
- **[Release](process/release-process.md)** - how we review contributions
3030

31-
## Technical
31+
## Using
3232

33-
These documents contain more details about the internals of GitHub for Unity
34-
and how things work:
33+
These documents contain more details on how to use the GitHub for Unity plugin:
34+
- **[Installing and Updating the GitHub for Unity package](https://github.com/github-for-unity/Unity/blob/master/docs/using/how-to-install-and-update.md)**
35+
- **[Getting Started with the GitHub for Unity package](https://github.com/github-for-unity/Unity/blob/master/docs/using/getting-started.md)**

src/GitHub.Api/Extensions/StringExtensions.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,22 @@
77

88
namespace GitHub.Unity
99
{
10+
static class DateTimeOffsetExtensions
11+
{
12+
private const string Today = "Today";
13+
private const string Yesterday = "Yesterday";
14+
15+
public static string CreateRelativeTime(this DateTimeOffset @from, DateTimeOffset to)
16+
{
17+
return String.Format("{0}, {1:HH}:{1:mm}",
18+
@from.DayOfYear == to.DayOfYear
19+
? Today
20+
: @from.DayOfYear == to.DayOfYear - 1
21+
? Yesterday
22+
: @from.ToString("d MMM yyyy"), @from);
23+
}
24+
}
25+
1026
static class StringExtensions
1127
{
1228
public static bool Contains(this string s, string expectedSubstring, StringComparison comparison)

src/GitHub.Api/Git/GitClient.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ public ITask<string> Unlock(NPath file, bool force,
306306
protected static ILogging Logger { get; } = LogHelper.GetLogger<GitClient>();
307307
}
308308

309+
[Serializable]
309310
public struct GitUser
310311
{
311312
public static GitUser Default = new GitUser();

src/GitHub.Api/Git/GitLock.cs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using System;
2+
using System.Globalization;
3+
using GitHub.Logging;
24

35
namespace GitHub.Unity
46
{
@@ -10,8 +12,24 @@ public struct GitLock
1012
public int id;
1113
public string path;
1214
public GitUser owner;
13-
public DateTimeOffset locked_at;
14-
15+
[NotSerialized] public string lockedAtString;
16+
public DateTimeOffset locked_at
17+
{
18+
get
19+
{
20+
DateTimeOffset dt;
21+
if (!DateTimeOffset.TryParseExact(lockedAtString, Constants.Iso8601Formats,
22+
CultureInfo.InvariantCulture, Constants.DateTimeStyle, out dt))
23+
{
24+
return DateTimeOffset.MinValue;
25+
}
26+
return dt;
27+
}
28+
set
29+
{
30+
lockedAtString = value.ToUniversalTime().ToString(Constants.Iso8601FormatZ, CultureInfo.InvariantCulture);
31+
}
32+
}
1533
[NotSerialized] public int ID => id;
1634
[NotSerialized] public NPath Path => path.ToNPath();
1735
[NotSerialized] public GitUser Owner => owner;
@@ -22,7 +40,7 @@ public GitLock(int id, NPath path, GitUser owner, DateTimeOffset locked_at)
2240
this.id = id;
2341
this.path = path;
2442
this.owner = owner;
25-
this.locked_at = locked_at;
43+
this.lockedAtString = locked_at.ToUniversalTime().ToString(Constants.Iso8601FormatZ, CultureInfo.InvariantCulture);
2644
}
2745

2846
public override bool Equals(object other)

src/GitHub.Api/Git/GitLogEntry.cs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ namespace GitHub.Unity
88
[Serializable]
99
public struct GitLogEntry
1010
{
11-
private const string Today = "Today";
12-
private const string Yesterday = "Yesterday";
13-
1411
public static GitLogEntry Default = new GitLogEntry(String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, DateTimeOffset.MinValue, DateTimeOffset.MinValue, new List<GitStatusEntry>(), String.Empty, String.Empty);
1512

1613
public string commitID;
@@ -61,18 +58,7 @@ public GitLogEntry(string commitID,
6158
this.mergeB = mergeB ?? string.Empty;
6259
}
6360

64-
public string PrettyTimeString
65-
{
66-
get
67-
{
68-
DateTimeOffset now = DateTimeOffset.Now, relative = Time.ToLocalTime();
69-
70-
return String.Format("{0}, {1:HH}:{1:mm}",
71-
relative.DayOfYear == now.DayOfYear
72-
? Today
73-
: relative.DayOfYear == now.DayOfYear - 1 ? Yesterday : relative.ToString("d MMM yyyy"), relative);
74-
}
75-
}
61+
public string PrettyTimeString => Time.ToLocalTime().CreateRelativeTime(DateTimeOffset.Now);
7662

7763
[NonSerialized] private DateTimeOffset? timeValue;
7864
public DateTimeOffset Time

src/GitHub.Api/Git/IRepository.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace GitHub.Unity
66
/// <summary>
77
/// Represents a repository, either local or retrieved via the GitHub API.
88
/// </summary>
9-
public interface IRepository : IEquatable<IRepository>, IDisposable
9+
public interface IRepository : IEquatable<IRepository>, IDisposable, IBackedByCache
1010
{
1111
void Initialize(IRepositoryManager theRepositoryManager, ITaskManager theTaskManager);
1212
void Start();
@@ -21,7 +21,6 @@ public interface IRepository : IEquatable<IRepository>, IDisposable
2121
ITask RequestLock(NPath file);
2222
ITask ReleaseLock(NPath file, bool force);
2323
ITask DiscardChanges(GitStatusEntry[] discardEntries);
24-
void CheckAndRaiseEventsIfCacheNewer(CacheType cacheType, CacheUpdateEvent cacheUpdateEvent);
2524

2625
/// <summary>
2726
/// Gets the name of the repository.

src/GitHub.Api/Git/Repository.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77

88
namespace GitHub.Unity
99
{
10+
public interface IBackedByCache
11+
{
12+
void CheckAndRaiseEventsIfCacheNewer(CacheType cacheType, CacheUpdateEvent cacheUpdateEvent);
13+
}
14+
1015
[DebuggerDisplay("{DebuggerDisplay,nq}")]
1116
sealed class Repository : IEquatable<Repository>, IRepository
1217
{
@@ -391,12 +396,11 @@ public string Name
391396
CloneUrl, LocalPath, CurrentBranch, CurrentRemote);
392397
}
393398

394-
public interface IUser
399+
public interface IUser : IBackedByCache
395400
{
396401
string Name { get; }
397402
string Email { get; }
398403
event Action<CacheUpdateEvent> Changed;
399-
void CheckUserChangedEvent(CacheUpdateEvent cacheUpdateEvent);
400404
void Initialize(IGitClient client);
401405
void SetNameAndEmail(string name, string email);
402406
}
@@ -417,7 +421,7 @@ public User(ICacheContainer cacheContainer)
417421
cacheContainer.CacheUpdated += (type, dt) => { if (type == CacheType.GitUser) CacheHasBeenUpdated(dt); };
418422
}
419423

420-
public void CheckUserChangedEvent(CacheUpdateEvent cacheUpdateEvent) => cacheContainer.CheckAndRaiseEventsIfCacheNewer(CacheType.GitUser, cacheUpdateEvent);
424+
public void CheckAndRaiseEventsIfCacheNewer(CacheType cacheType, CacheUpdateEvent cacheUpdateEvent) => cacheContainer.CheckAndRaiseEventsIfCacheNewer(CacheType.GitUser, cacheUpdateEvent);
421425

422426
public void Initialize(IGitClient client)
423427
{

src/GitHub.Api/Helpers/Constants.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using System.Globalization;
2+
13
namespace GitHub.Unity
24
{
35
static class Constants
@@ -11,11 +13,12 @@ static class Constants
1113
public const string Iso8601Format = @"yyyy-MM-dd\THH\:mm\:ss.fffzzz";
1214
public const string Iso8601FormatZ = @"yyyy-MM-dd\THH\:mm\:ss\Z";
1315
public static readonly string[] Iso8601Formats = {
14-
@"yyyy-MM-dd\THH\:mm\:ss\Z",
16+
Iso8601FormatZ,
1517
@"yyyy-MM-dd\THH\:mm\:ss.fffffffzzz",
16-
@"yyyy-MM-dd\THH\:mm\:ss.fffzzz",
18+
Iso8601Format,
1719
@"yyyy-MM-dd\THH\:mm\:sszzz",
1820
};
21+
public const DateTimeStyles DateTimeStyle = DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal;
1922
public const string SkipVersionKey = "SkipVersion";
2023
public const string GitInstallationState = "GitInstallationState";
2124

src/GitHub.Api/Helpers/SimpleJson.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1255,7 +1255,7 @@ class PocoJsonSerializerStrategy : IJsonSerializerStrategy
12551255
@"yyyy-MM-dd\THH\:mm\:sszzz",
12561256
@"yyyy-MM-dd\THH\:mm\:ss.fffffffzzz",
12571257
@"yyyy-MM-dd\THH\:mm\:ss.fffzzz",
1258-
@"yyyy-MM-dd\THH\:mm\:ssZ",
1258+
@"yyyy-MM-dd\THH\:mm\:ss\Z",
12591259
@"yyyy-MM-dd\THH:mm:ss.fffffffzzz",
12601260
@"yyyy-MM-dd\THH:mm:ss.fffzzz",
12611261
@"yyyy-MM-dd\THH:mm:sszzz",

0 commit comments

Comments
 (0)