1#
2#    Copyright 2018 Google LLC. All Rights Reserved.
3#    Copyright 2017-2018 Nest Labs Inc. All Rights Reserved.
4#
5#    Licensed under the Apache License, Version 2.0 (the "License");
6#    you may not use this file except in compliance with the License.
7#    You may obtain a copy of the License at
8#
9#    http://www.apache.org/licenses/LICENSE-2.0
10#
11#    Unless required by applicable law or agreed to in writing, software
12#    distributed under the License is distributed on an "AS IS" BASIS,
13#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14#    See the License for the specific language governing permissions and
15#    limitations under the License.
16#
17
18#
19#    Description:
20#      This file is the make "header" or pre make header that defines make
21#      convenience macros for interacting with git.
22#
23
24# nlGitGetConfigFromFileCommand <file>
25#
26# Command to get a value for a variable set in the specified git config file <file>.
27
28nlGitGetConfigFromFileCommand         = $(GIT) config --file $(1)
29
30# nlGitListConfigFromFileCommand <file>
31#
32# Command to list all variables set in the specified config file <file>
33
34nlGitListConfigFromFileCommand        = $(call nlGitGetConfigFromFileCommand,$(1)) --list
35
36# nlGitGetConfigFromFile <file>
37#
38# Get a value for a variable set in the specified git config file <file>.
39
40nlGitGetConfigFromFile                = $(shell $(call nlGitGetConfigFromFileCommand,$(1)))
41
42# nlGitListConfigFromFile <file>
43#
44# List all variables set in the specified config file <file>
45
46nlGitListConfigFromFile               = $(shell $(call nlGitListConfigFromFileCommand,$(1)))
47
48# nlGitGetValueForRepoFromNameFromFile <file> <repo name> <value>
49#
50# Get a value for a repo / submodule variable set in specified git config file <file>.
51
52nlGitGetValueForRepoFromNameFromFile  = $(shell $(call nlGitGetConfigFromFileCommand,$(1)) 'submodule.$(2).$(3)')
53
54# nlGitGetBranchForRepoFromNameFromFile <file> <repo name>
55#
56# Get the remote branch for a repo / submodule variable set in specified git config file <file>.
57
58nlGitGetBranchForRepoFromNameFromFile = $(call nlGitGetValueForRepoFromNameFromFile,$(1),$(2),branch)
59
60# nlGitGetCommitForRepoFromNameFromFile <file> <repo name>
61#
62# Get the commit for a repo / submodule variable set in specified git config file <file>.
63
64nlGitGetCommitForRepoFromNameFromFile = $(call nlGitGetValueForRepoFromNameFromFile,$(1),$(2),commit)
65
66# nlGitGetURLForRepoFromNameFromFile <file> <repo name>
67#
68# Get the remote URL for a repo / submodule variable set in specified git config file <file>.
69
70nlGitGetURLForRepoFromNameFromFile    = $(call nlGitGetValueForRepoFromNameFromFile,$(1),$(2),url)
71
72# nlGitGetPathForRepoFromNameFromFile <file> <repo name>
73#
74# Get the local path for a repo / submodule variable set in specified git config file <file>.
75
76nlGitGetPathForRepoFromNameFromFile   = $(call nlGitGetValueForRepoFromNameFromFile,$(1),$(2),path)
77
78# nlGitGetMethodForPullFromFile <file>
79#
80# Get the pull method set in specified git config file <file>.
81
82nlGitGetMethodForPullFromFile         = $(shell $(call nlGitGetConfigFromFileCommand,$(1)) 'pull.method')
83
84