feat: retreive commit scope
This commit is contained in:
		
							parent
							
								
									15b4e6c020
								
							
						
					
					
						commit
						00e0202f62
					
				
							
								
								
									
										53
									
								
								joj-repo
									
									
									
									
									
								
							
							
						
						
									
										53
									
								
								joj-repo
									
									
									
									
									
								
							|  | @ -1,8 +1,41 @@ | ||||||
| #!/bin/bash | #!/bin/bash | ||||||
| 
 | 
 | ||||||
| COURSE=$(hostname) | GITEA="ssh://git@focs.ji.sjtu.edu.cn:2222" | ||||||
| SEMESTER=${COURSE#*-} | ORG=${GITHUB_ACTION_REPOSITORY%/*} | ||||||
| COURSE=${COURSE%-*} | COURSE=${ORG/-*} | ||||||
|  | 
 | ||||||
|  | LXCHOST="tt@172.17.0.1" | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | # | ||||||
|  | # parse commit message | ||||||
|  | # | ||||||
|  | 
 | ||||||
|  | parse_commit() { | ||||||
|  | 
 | ||||||
|  | 	message=$(git log -1 --pretty=format:%s ${GITHUB_WORKFLOW_SHA}) | ||||||
|  | 
 | ||||||
|  | 	# add empty scope if none provided, then split "type(scope): message" | ||||||
|  | 	OLDIFS=$IFS; IFS=$'\n' | ||||||
|  | 	commit=( $(sed 's/\(^[^(]*\):/\1( ):/g; s/\([^(]*\)(\?\([^)]*\))\?: \(.*\)/\1\n\2\n\3/g' <<< ${message}) ) | ||||||
|  | 	IFS=$OLDIFS | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | # | ||||||
|  | # gen  | ||||||
|  | # | ||||||
|  | 
 | ||||||
|  | generate_json() { | ||||||
|  | 
 | ||||||
|  | 	parse_commit | ||||||
|  | 	for i in ${commit[1]}; do  | ||||||
|  | 		echo joj-conf-generator $HOME/.config/joj/$i | ||||||
|  | 	done | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| # | # | ||||||
| # initial repo/config setup | # initial repo/config setup | ||||||
|  | @ -11,7 +44,7 @@ init() { | ||||||
| 
 | 
 | ||||||
|         [ -d $COURSE-config ] && backup $COURSE-config |         [ -d $COURSE-config ] && backup $COURSE-config | ||||||
| 
 | 
 | ||||||
|         git clone ssh://git@focs.ji.sjtu.edu.cn:2222/$COURSE-$SEMESTER/$COURSE-joj.git $COURSE-config |         git clone $GITEA/$ORG/$COURSE-joj.git $COURSE-config | ||||||
| 
 | 
 | ||||||
|         cd $COURSE-config |         cd $COURSE-config | ||||||
| 
 | 
 | ||||||
|  | @ -28,12 +61,12 @@ init() { | ||||||
| 
 | 
 | ||||||
| # clone grading branch or create one + push readme | # clone grading branch or create one + push readme | ||||||
|         if [ "x$br" = "x1" ]; then |         if [ "x$br" = "x1" ]; then | ||||||
|                 git clone -b grading ssh://git@focs.ji.sjtu.edu.cn:2222/$COURSE-$SEMESTER/$COURSE-joj.git |                 git clone -b grading $GITEA/$COURSE-$SEMESTER/$COURSE-joj.git | ||||||
|                 cd $COURSE-joj |                 cd $COURSE-joj | ||||||
|                 git switch grading |                 git switch grading | ||||||
|                 git pull |                 git pull | ||||||
|         else |         else | ||||||
|                 git clone ssh://git@focs.ji.sjtu.edu.cn:2222/$COURSE-$SEMESTER/$COURSE-joj.git |                 git clone $GITEA/$COURSE-$SEMESTER/$COURSE-joj.git | ||||||
| 
 | 
 | ||||||
|                 cd $COURSE-joj |                 cd $COURSE-joj | ||||||
|                 git switch --orphan grading |                 git switch --orphan grading | ||||||
|  | @ -48,20 +81,22 @@ init() { | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| # | # | ||||||
| # update config repo + copy config files | # update config repo + copy config files | ||||||
| # | # | ||||||
| update() { | update() { | ||||||
| 
 | 
 | ||||||
|         [ -d "$COURSE-joj" ] || ( echo "ERROR: init first!" 1>&2 && exit ) |         [ -d "$COURSE-joj" ] || ( echo "ERROR: init first!" 1>&2 && exit ) | ||||||
|         cd $HOME/.cache/$COURSE-config |  | ||||||
| 
 | 
 | ||||||
|         git pull |  | ||||||
| 
 | 
 | ||||||
|         rsync -r ./$HOME/ $HOME | #				genjson | ||||||
|  | 
 | ||||||
|  |         rsync -a ./$HOME/ $LXCHOST:$HOME | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| # | # | ||||||
| # simple local backup | # simple local backup | ||||||
| # | # | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user