@sasjs/core 4.42.0 → 4.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,46 @@
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 != `"TRUE"` then the file is staged (so you could provide an empty
8
+ char column if staging all observations).
9
+
10
+ Usage:
11
+
12
+ %let dir=%sysfunc(pathname(work))/core;
13
+ %let repo=https://github.com/sasjs/core;
14
+ %put source clone rc=%sysfunc(GITFN_CLONE(&repo,&dir));
15
+ %mf_writefile(&dir/somefile.txt,l1=some content)
16
+ %mf_deletefile(&dir/package.json)
17
+ %mp_gitstatus(&dir,outds=work.gitstatus)
18
+
19
+ %mp_gitadd(&dir,inds=work.gitstatus)
20
+
21
+ @param [in] gitdir The directory containing the GIT repository
22
+ @param [in] inds= (work.mp_gitadd) The input dataset with the list of files
23
+ to stage. Will accept the output from mp_gitstatus(), else just use a table
24
+ with the following columns:
25
+ @li path $1024 - relative path to the file in the repo
26
+ @li staged $32 - whether the file is staged (TRUE or FALSE)
27
+ @li status $64 - either new, deleted, or modified
28
+
29
+ @param [in] mdebug= (0) Set to 1 to enable DEBUG messages
30
+
31
+ <h4> Related Files </h4>
32
+ @li mp_gitadd.test.sas
33
+ @li mp_gitstatus.sas
34
+
35
+ **/
36
+
37
+ %macro mp_gitadd(gitdir,inds=work.mp_gitadd,mdebug=0);
38
+
39
+ data _null_;
40
+ set &inds;
41
+ if STAGED ne "TRUE";
42
+ rc=git_index_add("&gitdir",cats(path),status);
43
+ if rc ne 0 or &mdebug=1 then put rc=;
44
+ run;
45
+
46
+ %mend mp_gitadd;
@@ -0,0 +1,67 @@
1
+ /**
2
+ @file
3
+ @brief Creates a dataset with the output from `GIT_STATUS()`
4
+ @details Uses `git_status()` to fetch the number of changed files, then
5
+ iterates through with `git_status_get()` and `git_index_add()` for each
6
+ change - which is created in an output dataset.
7
+
8
+ Usage:
9
+
10
+ %let dir=%sysfunc(pathname(work))/core;
11
+ %let repo=https://github.com/sasjs/core;
12
+ %put source clone rc=%sysfunc(GITFN_CLONE(&repo,&dir));
13
+ %mf_writefile(&dir/somefile.txt,l1=some content)
14
+ %mf_deletefile(&dir/package.json)
15
+
16
+ %mp_gitstatus(&dir,outds=work.gitstatus)
17
+
18
+ More info on these functions is in this [helpful paper](
19
+ https://www.sas.com/content/dam/SAS/support/en/sas-global-forum-proceedings/2019/3057-2019.pdf
20
+ ) by Danny Zimmerman.
21
+
22
+ @param [in] gitdir The directory containing the GIT repository
23
+ @param [out] outds= (work.git_status) The output dataset to create. Vars:
24
+ @li gitdir $1024 - directory of repo
25
+ @li path $1024 - relative path to the file in the repo
26
+ @li staged $32 - whether the file is staged (TRUE or FALSE)
27
+ @li status $64 - either new, deleted, or modified
28
+ @li cnt - number of files
29
+ @li n - the "nth" file in the list from git_status()
30
+
31
+ @param [in] mdebug= (0) Set to 1 to enable DEBUG messages
32
+
33
+ <h4> Related Files </h4>
34
+ @li mp_gitstatus.test.sas
35
+ @li mp_gitadd.sas
36
+
37
+ **/
38
+
39
+ %macro mp_gitstatus(gitdir,outds=work.mp_gitstatus,mdebug=0);
40
+
41
+ data &outds;
42
+ LENGTH gitdir path $ 1024 STATUS $ 64 STAGED $ 32;
43
+ call missing (of _all_);
44
+ gitdir=symget('gitdir');
45
+ cnt=git_status(trim(gitdir));
46
+ if cnt=-1 then do;
47
+ put "The libgit2 library is unavailable and no Git operations can be used.";
48
+ put "See: https://stackoverflow.com/questions/74082874";
49
+ end;
50
+ else if cnt=-2 then do;
51
+ put "The libgit2 library is available, but the status function failed.";
52
+ put "See the log for details.";
53
+ end;
54
+ else do n=1 to cnt;
55
+ rc=GIT_STATUS_GET(n,gitdir,'PATH',path);
56
+ rc=GIT_STATUS_GET(n,gitdir,'STAGED',staged);
57
+ rc=GIT_STATUS_GET(n,gitdir,'STATUS',status);
58
+ output;
59
+ %if &mdebug=1 %then %do;
60
+ putlog (_all_)(=);
61
+ %end;
62
+ end;
63
+ rc=git_status_free(gitdir);
64
+ drop rc cnt;
65
+ run;
66
+
67
+ %mend mp_gitstatus;
package/package.json CHANGED
@@ -35,5 +35,5 @@
35
35
  "devDependencies": {
36
36
  "@sasjs/cli": "3.13.0"
37
37
  },
38
- "version": "4.42.0"
38
+ "version": "4.43.0"
39
39
  }