예제 #1
0
        public const string COMMIT_LOG_TAG        = "#COMMIT_LOG#";                // コミットログ置換対象のタグ

        //================================================================================
        // 関数(static)
        //================================================================================
        /// <summary>
        /// Git の情報を管理するスクリプトを生成します
        /// </summary>
        /// <example>
        /// <code>
        /// var outputPath = "Assets/Scripts/GitInfo.cs";
        ///
        /// var option = new CommitLogOption
        ///	(
        ///		count: 10,
        ///		isNoMerges: false,
        ///		format: "%h %cd %cn %s"
        /// );
        ///
        /// var template = $@"public static class GitInfo
        /// {{
        ///     public const string BRANCH_NAME       = ""{GitCodeGenerator.BRANCH_NAME_TAG}"";
        ///     public const string COMMIT_HASH       = ""{GitCodeGenerator.COMMIT_HASH_TAG}"";
        ///     public const string SHORT_COMMIT_HASH = ""{GitCodeGenerator.SHORT_COMMIT_HASH_TAG}"";
        ///     public const string COMMIT_LOG_TAG    = @""{GitCodeGenerator.COMMIT_LOG_TAG}"";
        /// }}";
        ///
        /// GitCommitHashCodeGenerator.Generate( outputPath, template, option );
        /// </code>
        /// </example>
        public static void Generate
        (
            string outputPath,
            string template,
            CommitLogOption commitLogOption
        )
        {
            // 出力先のフォルダが存在しない場合は作成します
            var dir = Path.GetDirectoryName(outputPath);

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            // Git の情報を読み込みます
            var branchName      = GitUtils.LoadBranchName();
            var commitHash      = GitUtils.LoadCommitHash();
            var shortCommitHash = GitUtils.LoadShortCommitHash();
            var commitLog       = GitUtils.LoadCommitLog(commitLogOption);

            // Git の情報を埋め込んだスクリプトの文字列を作成します
            var code = template;

            code = code.Replace(BRANCH_NAME_TAG, branchName);
            code = code.Replace(COMMIT_HASH_TAG, commitHash);
            code = code.Replace(SHORT_COMMIT_HASH_TAG, shortCommitHash);
            code = code.Replace(COMMIT_LOG_TAG, commitLog);

            // 作成した文字列をスクリプトとして保存します
            File.WriteAllText(outputPath, code);
            AssetDatabase.Refresh();
        }
예제 #2
0
        private static void CopyCommitLog()
        {
            var option = new CommitLogOption
                         (
                count: 10,
                isNoMerges: false,
                format: "%h %cd %cn %s"
                         );

            GUIUtility.systemCopyBuffer = GitUtils.LoadCommitLog(option);
        }
예제 #3
0
        private static void LogCommitLog()
        {
            var option = new CommitLogOption
                         (
                count: 10,
                isNoMerges: false,
                format: "%h %cd %cn %s"
                         );

            Debug.Log($"[UniGitUtils]\n{GitUtils.LoadCommitLog( option )}");
        }
예제 #4
0
 private static void CopyShortCommitHash()
 {
     GUIUtility.systemCopyBuffer = GitUtils.LoadShortCommitHash();
 }
예제 #5
0
 private static void LogShortCommitHash()
 {
     Debug.Log($"[UniGitUtils] {GitUtils.LoadShortCommitHash()}");
 }
예제 #6
0
 private static void CopyBranchName()
 {
     GUIUtility.systemCopyBuffer = GitUtils.LoadBranchName();
 }
예제 #7
0
 private static void LogBranchName()
 {
     Debug.Log($"[UniGitUtils] {GitUtils.LoadBranchName()}");
 }