Macros for SAS Application Developers
https://github.com/sasjs/core
mp_gitadd.sas
Go to the documentation of this file.
1 /**
2  @file
3  @brief Stages files in a GIT repo
4  @details Uses the output dataset from mp_gitstatus.sas to determine the files
5  that should be staged.
6 
7  If `STAGED ne "TRUE"` then the file is staged.
8 
9  Usage:
10 
11  %let dir=%sysfunc(pathname(work))/core;
12  %let repo=https://github.com/sasjs/core;
13  %put source clone rc=%sysfunc(GITFN_CLONE(&repo,&dir));
14  %mf_writefile(&dir/somefile.txt,l1=some content)
15  %mf_deletefile(&dir/package.json)
16  %mp_gitstatus(&dir,outds=work.gitstatus)
17 
18  %mp_gitadd(&dir,inds=work.gitstatus)
19 
20  @param [in] gitdir The directory containing the GIT repository
21  @param [in] inds= (work.mp_gitadd) The input dataset with the list of files
22  to stage. Will accept the output from mp_gitstatus(), else just use a table
23  with the following columns:
24  @li path $1024 - relative path to the file in the repo
25  @li staged $32 - whether the file is staged (TRUE or FALSE)
26  @li status $64 - either new, deleted, or modified
27 
28  @param [in] mdebug= (0) Set to 1 to enable DEBUG messages
29 
30  <h4> Related Files </h4>
31  @li mp_gitadd.test.sas
32  @li mp_gitstatus.sas
33 
34 **/
35 
36 %macro mp_gitadd(gitdir,inds=work.mp_gitadd,mdebug=0);
37 
38 data _null_;
39  set &inds;
40  if STAGED ne "TRUE";
41  rc=git_index_add("&gitdir",cats(path),status);
42  if rc ne 0 or &mdebug=1 then put rc=;
43 run;
44 
45 %mend mp_gitadd;