diff options
| author | ruki <[email protected]> | 2019-03-26 22:41:32 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-03-26 10:09:13 +0800 |
| commit | baa44e2c153a39558968740b5799b26ed7f546df (patch) | |
| tree | 490b9044bccec99d973fc806d8690214f88912b7 /xmake/modules/devel/git/apply.lua | |
| parent | 68c02694b246cd6e11e3d18e8cb4327877144c74 (diff) | |
uses git.apply to instead of patch
Diffstat (limited to 'xmake/modules/devel/git/apply.lua')
| -rw-r--r-- | xmake/modules/devel/git/apply.lua | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/xmake/modules/devel/git/apply.lua b/xmake/modules/devel/git/apply.lua new file mode 100644 index 000000000..b5749b7cc --- /dev/null +++ b/xmake/modules/devel/git/apply.lua @@ -0,0 +1,67 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015 - 2019, TBOOX Open Source Group. +-- +-- @author ruki +-- @file apply.lua +-- + +-- imports +import("core.base.option") +import("lib.detect.find_tool") + +-- apply remote commits +-- +-- @param opt the argument options +-- +-- @code +-- +-- import("devel.git") +-- +-- git.apply("xxx.patch") +-- git.apply("xxx.diff") +-- +-- @endcode +-- +function main(patchfile, opt) + + -- find git + local git = find_tool("git") + if not git then + return + end + + -- init argv + opt = opt or {} + local argv = {"apply", "--reject", patchfile} + + -- enter repository directory + local oldir = nil + if opt.repodir then + oldir = os.cd(opt.repodir) + end + + -- apply it + os.vrunv(git.program, argv) + + -- leave repository directory + if oldir then + os.cd(oldir) + end +end |
