From 46c3729e2d7a604d7784f8d7691433997369f5d6 Mon Sep 17 00:00:00 2001 From: leedongmyung Date: Sat, 22 Nov 2025 11:16:32 +0900 Subject: [PATCH] =?UTF-8?q?git=20pull=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/oto/commands/command.dart | 2 ++ lib/oto/commands/git/git.dart | 15 +++++++++++++++ lib/oto/data/command_data.dart | 13 +++++++++++++ lib/oto/data/command_data.g.dart | 21 +++++++++++++++++++++ 4 files changed, 51 insertions(+) diff --git a/lib/oto/commands/command.dart b/lib/oto/commands/command.dart index f40834a..8c1f3d1 100644 --- a/lib/oto/commands/command.dart +++ b/lib/oto/commands/command.dart @@ -94,6 +94,7 @@ enum CommandType { ShellFile, Git, GitCommit, + GitPull, GitPush, GitCheckout, GitRev, @@ -171,6 +172,7 @@ abstract class Command { CommandType.ShellFile: () => ShellFile(), CommandType.Git: () => Git(), CommandType.GitCommit: () => GitCommit(), + CommandType.GitPull: () => GitPull(), CommandType.GitPush: () => GitPush(), CommandType.GitCheckout: () => GitCheckout(), CommandType.GitRev: () => GitRev(), diff --git a/lib/oto/commands/git/git.dart b/lib/oto/commands/git/git.dart index 7226622..ab0a1c6 100644 --- a/lib/oto/commands/git/git.dart +++ b/lib/oto/commands/git/git.dart @@ -47,6 +47,21 @@ class GitCommit extends Command { } } +class GitPull extends Command { + @override + Future execute(DataCommand command) async { + var data = DataGitPush.fromJson(getParam(command)); + + var shell = StringBuffer(getCDPath(workspace)); + shell.write(' $and git pull origin ${data.branch}'); + + var process = + await ProcessExecutor.start(shell, logHandler: Application.logWithType); + return await completeProcess(process, command, + passExitCodes: [1 /*Everything up-to-date*/]); + } +} + //무시가가능한 에러 무시 class GitPush extends Command { @override diff --git a/lib/oto/data/command_data.dart b/lib/oto/data/command_data.dart index 31c5bab..c577f64 100644 --- a/lib/oto/data/command_data.dart +++ b/lib/oto/data/command_data.dart @@ -753,6 +753,19 @@ class BranchInfo { Map toJson() => _$BranchInfoToJson(this); } +//GitPull +@JsonSerializable() +class DataGitPull extends DataParam { + DataGitPull(); + + late String branch; + + factory DataGitPull.fromJson(Map json) => + _$DataGitPullFromJson(json); + @override + Map toJson() => _$DataGitPullToJson(this); +} + //GitPush @JsonSerializable() class DataGitPush extends DataParam { diff --git a/lib/oto/data/command_data.g.dart b/lib/oto/data/command_data.g.dart index 5a984d3..cd1fbf2 100644 --- a/lib/oto/data/command_data.g.dart +++ b/lib/oto/data/command_data.g.dart @@ -99,6 +99,7 @@ const _$CommandTypeEnumMap = { CommandType.ShellFile: 'ShellFile', CommandType.Git: 'Git', CommandType.GitCommit: 'GitCommit', + CommandType.GitPull: 'GitPull', CommandType.GitPush: 'GitPush', CommandType.GitCheckout: 'GitCheckout', CommandType.GitRev: 'GitRev', @@ -1320,6 +1321,26 @@ Map _$BranchInfoToJson(BranchInfo instance) => 'date': instance.date, }; +DataGitPull _$DataGitPullFromJson(Map json) => DataGitPull() + ..workspace = json['workspace'] as String? + ..passExitCodes = (json['passExitCodes'] as List?) + ?.map((e) => (e as num).toInt()) + .toList() + ..setResult = json['setResult'] as String? + ..setExitCode = json['setExitCode'] as String? + ..showPrint = json['showPrint'] as bool? + ..branch = json['branch'] as String; + +Map _$DataGitPullToJson(DataGitPull instance) => + { + 'workspace': instance.workspace, + 'passExitCodes': instance.passExitCodes, + 'setResult': instance.setResult, + 'setExitCode': instance.setExitCode, + 'showPrint': instance.showPrint, + 'branch': instance.branch, + }; + DataGitPush _$DataGitPushFromJson(Map json) => DataGitPush() ..workspace = json['workspace'] as String? ..passExitCodes = (json['passExitCodes'] as List?)